Explorar o código

replace app with appDelegate

Marino Faggiana %!s(int64=7) %!d(string=hai) anos
pai
achega
205a848dfe

+ 2 - 2
iOSClient/Main/CCDetail.m

@@ -62,6 +62,8 @@
 {
     if (self = [super initWithCoder:aDecoder])  {
         
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backNavigationController) name:@"detailBack" object:nil];
@@ -87,8 +89,6 @@
 {
     [super viewDidLoad];
     
-    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-    
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(insertGeocoderLocation:) name:@"insertGeocoderLocation" object:nil];
 
     self.imageBackground.image = [UIImage imageNamed:@"backgroundDetail"];

+ 2 - 10
iOSClient/Main/CCMain.m

@@ -107,6 +107,8 @@
 {    
     if (self = [super initWithCoder:aDecoder])  {
         
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
         _directoryOrder = [CCUtility getOrderSettings];
         _directoryGroupBy = [CCUtility getGroupBySettings];
         
@@ -127,8 +129,6 @@
 - (void)viewDidLoad
 {
     [super viewDidLoad];
-
-    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     
     // init object
     _metadata = [tableMetadata new];
@@ -334,8 +334,6 @@
 
 - (void)initializeMain:(NSNotification *)notification
 {
-    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-
     _directoryGroupBy = nil;
     _directoryOrder = nil;
     _dateReadDataSource = nil;
@@ -1012,8 +1010,6 @@
 
 - (void)getNotificationServerSuccess:(NSArray *)listOfNotifications
 {
-    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-    
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
         
         // Order by date
@@ -2604,8 +2600,6 @@
 {
     [_hud hideHud];
     
-    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-    
     // change account ?
     tableAccount *record = [[NCManageDatabase sharedInstance] getAccountActive];
     if([record.account isEqualToString:metadataNet.account] == NO)
@@ -2686,8 +2680,6 @@
 {
     [_hud hideHud];
     
-    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-
     // rimuoviamo la condivisione da db
     NSArray *result = [[NCManageDatabase sharedInstance] unShare:metadataNet.share fileName:metadataNet.fileName serverUrl:metadataNet.serverUrl sharesLink:appDelegate.sharesLink sharesUserAndGroup:appDelegate.sharesUserAndGroup];
     

+ 3 - 3
iOSClient/Main/CCSplit.m

@@ -41,7 +41,9 @@
 
 -  (id)initWithCoder:(NSCoder *)aDecoder
 {
-    if (self = [super initWithCoder:aDecoder])  {        
+    if (self = [super initWithCoder:aDecoder])  {
+        
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     }
     
     return self;
@@ -51,8 +53,6 @@
 {
     [super viewDidLoad];
 
-    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-
     [self inizialize];    
 }
 

+ 6 - 2
iOSClient/Networking/CCNetworking.m

@@ -990,7 +990,9 @@
                 [[NCManageDatabase sharedInstance] deleteQueueUploadWithAssetLocalIdentifier:assetLocalIdentifier selector:selector];
 #ifndef EXTENSION
                 // Next tableQueueUpload
-                [(AppDelegate *)[[UIApplication sharedApplication] delegate] performSelectorOnMainThread:@selector(loadAutoDownloadUpload:) withObject:[NSNumber numberWithInt:k_maxConcurrentOperationDownloadUpload] waitUntilDone:NO];
+                AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
+                [appDelegate performSelectorOnMainThread:@selector(loadAutoDownloadUpload:) withObject:[NSNumber numberWithInt:k_maxConcurrentOperationDownloadUpload] waitUntilDone:NO];
 #endif
             });
             
@@ -1004,7 +1006,9 @@
              [[NCManageDatabase sharedInstance] deleteQueueUploadWithAssetLocalIdentifier:assetLocalIdentifier selector:selector];
 #ifndef EXTENSION
              // Next tableQueueUpload
-             [(AppDelegate *)[[UIApplication sharedApplication] delegate] performSelectorOnMainThread:@selector(loadAutoDownloadUpload:) withObject:[NSNumber numberWithInt:k_maxConcurrentOperationDownloadUpload] waitUntilDone:NO];
+             AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
+             [appDelegate performSelectorOnMainThread:@selector(loadAutoDownloadUpload:) withObject:[NSNumber numberWithInt:k_maxConcurrentOperationDownloadUpload] waitUntilDone:NO];
 #endif
              
              // Manage uploadTask cancel,suspend,resume

+ 18 - 6
iOSClient/Networking/OCNetworking.m

@@ -220,7 +220,9 @@
         if ([items count] == 0) {
             
 #ifndef EXTENSION
-            [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"Server error" description:@"Read Folder WebDAV : [items NULL] please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError  errorCode:0];
+            AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
+            [appDelegate messageNotification:@"Server error" description:@"Read Folder WebDAV : [items NULL] please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError  errorCode:0];
 #endif
 
             dispatch_async(dispatch_get_main_queue(), ^{
@@ -305,7 +307,9 @@
                 // ----- BUG #942 ---------
                 if ([itemDto.etag length] == 0) {
 #ifndef EXTENSION
-                    [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
+                    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
+                    [appDelegate messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
 #endif
                     continue;
                 }
@@ -402,7 +406,9 @@
                 // ----- BUG #942 ---------
                 if ([itemDto.etag length] == 0) {
 #ifndef EXTENSION
-                    [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
+                    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
+                    [appDelegate messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
 #endif
                     continue;
                 }
@@ -562,7 +568,9 @@
             // ----- BUG #942 ---------
             if ([itemDto.etag length] == 0) {
 #ifndef EXTENSION
-                [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
+                AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
+                [appDelegate messageNotification:@"Server error" description:@"Metadata fileID absent, record excluded, please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
 #endif
                 continue;
             }
@@ -870,7 +878,9 @@
         if ([items count] == 0) {
        
 #ifndef EXTENSION
-            [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"Server error" description:@"Read File WebDAV : [items NULL] please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
+            AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
+            [appDelegate messageNotification:@"Server error" description:@"Read File WebDAV : [items NULL] please fix" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
 #endif
             if([self.delegate respondsToSelector:@selector(readFileFailure:message:errorCode:)])
                 [self.delegate readFileFailure:_metadataNet message:@"Read File WebDAV : [items NULL] please fix" errorCode:0];
@@ -1051,7 +1061,9 @@
     } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
         
 #ifndef EXTENSION
-        [(AppDelegate *)[[UIApplication sharedApplication] delegate] messageNotification:@"_error_" description:[CCError manageErrorOC:response.statusCode error:error] visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:error.code];
+        AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
+        [appDelegate messageNotification:@"_error_" description:[CCError manageErrorOC:response.statusCode error:error] visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:error.code];
 #endif
         
         NSInteger errorCode = response.statusCode;

+ 0 - 1
iOSClient/PeekPop/CCPeekPop.m

@@ -30,7 +30,6 @@
 @interface CCPeekPop ()
 {
     AppDelegate *appDelegate;
-
 }
 @end
 

+ 2 - 0
iOSClient/Photos/CCPhotos.m

@@ -70,6 +70,8 @@
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     
     if (self) {
+        
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     }
     
     return self;

+ 0 - 9
iOSClient/Settings/Acknowledgements.m

@@ -32,15 +32,6 @@
 
 @implementation Acknowledgements
 
--  (id)initWithCoder:(NSCoder *)aDecoder
-{
-    if (self = [super initWithCoder:aDecoder])  {
-        
-    }
-    
-    return self;
-}
-
 - (void)viewDidLoad
 {
     [super viewDidLoad];

+ 2 - 2
iOSClient/Settings/CCAdvanced.m

@@ -40,6 +40,8 @@
     XLFormSectionDescriptor *section;
     XLFormRowDescriptor *row;
     
+    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
     
     form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_advanced_", nil)];
@@ -152,8 +154,6 @@
 {
     [super viewDidLoad];
     
-    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-
     _hud = [[CCHud alloc] initWithView:[[[UIApplication sharedApplication] delegate] window]];
 }
 

+ 4 - 1
iOSClient/Settings/CCManageAutoUpload.m

@@ -39,6 +39,8 @@
 {
     if (self = [super initWithCoder:aDecoder])  {
         
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
         [self initializeForm];
     }
     
@@ -52,6 +54,8 @@
     
     if (self) {
         
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
         UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done:)];
         self.navigationItem.rightBarButtonItem = doneButton;
         
@@ -67,7 +71,6 @@
     XLFormSectionDescriptor *section;
     XLFormRowDescriptor *row;
  
-    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];

+ 2 - 0
iOSClient/Settings/NCManageEndToEndEncryption.m

@@ -42,6 +42,7 @@
 {
     self = [super initWithCoder:aDecoder];
     if (self) {
+        
         appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
         
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadForm) name:@"reloadManageEndToEndEncryption" object:nil];
@@ -54,6 +55,7 @@
 {
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     if (self) {
+        
         appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
         
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadForm) name:@"reloadManageEndToEndEncryption" object:nil];

+ 2 - 3
iOSClient/Share/CCShareInfoCMOC.m

@@ -50,7 +50,8 @@ const PERMISSION_ALL = 31;
 {
     self = [super initWithCoder:coder];
     if (self) {
-                
+        
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     }
     return self;
 }
@@ -116,8 +117,6 @@ const PERMISSION_ALL = 31;
 {
     [super viewDidLoad];
     
-    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-
     self.view.backgroundColor = [NCBrandColor sharedInstance].backgroundView;
     
     [self.endButton setTitle:NSLocalizedString(@"_done_", nil) forState:UIControlStateNormal];

+ 1 - 3
iOSClient/Share/CCShareOC.m

@@ -153,9 +153,7 @@
 #pragma --------------------------------------------------------------------------------------------
 
 - (void)reloadData
-{
-    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-    
+{    
     // bugfix
     if (!self.serverUrl || !self.metadata) {
         

+ 1 - 2
iOSClient/Share/CCSharePermissionOC.m

@@ -39,6 +39,7 @@
     self = [super initWithCoder:coder];
     if (self) {
         
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
     }
     return self;
 }
@@ -147,8 +148,6 @@
 {
     [super viewDidLoad];
     
-    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-
     self.view.backgroundColor = [NCBrandColor sharedInstance].backgroundView;
     
     [self.endButton setTitle:NSLocalizedString(@"_done_", nil) forState:UIControlStateNormal];

+ 2 - 2
iOSClient/Share/CCShareUserOC.m

@@ -38,6 +38,8 @@
     self = [super initWithCoder:coder];
     if (self) {
         
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
         self.directUser = @"";
         
         [self initializeForm];
@@ -96,8 +98,6 @@
 {
     [super viewDidLoad];
     
-    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-    
     self.selectedItems = [[NSMutableArray alloc] init];
     
     self.view.backgroundColor = [NCBrandColor sharedInstance].backgroundView;

+ 2 - 2
iOSClient/Shares/NCShares.m

@@ -43,6 +43,8 @@
 {
     if (self = [super initWithCoder:aDecoder])  {
         
+        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
+
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerProgressTask:) name:@"NotificationProgressTask" object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
         
@@ -55,8 +57,6 @@
 {
     [super viewDidLoad];
     
-    appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
-    
     // Custom Cell
     [self.tableView registerNib:[UINib nibWithNibName:@"NCSharesCell" bundle:nil] forCellReuseIdentifier:@"Cell"];