From 953d4d80fd03f1f73df5c9bc191de84a1696101c Mon Sep 17 00:00:00 2001 From: Frederic Jacobs Date: Mon, 6 Oct 2014 10:05:55 +0200 Subject: [PATCH] Syntax fixes from #172 //FREEBIE --- Signal/src/AppDelegate.m | 20 +++++++++---------- Signal/src/environment/VersionMigrations.m | 6 +++--- Signal/src/network/PushManager.m | 7 +++++-- .../network/http/RPServerRequestsManager.h | 4 +++- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index c37f82052..6140a0b49 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -81,22 +81,22 @@ NSError *error; NSDictionary *attrs = @{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication}; - [[NSFileManager defaultManager] setAttributes:attrs ofItemAtPath:preferencesPath error:&error]; + [NSFileManager.defaultManager setAttributes:attrs ofItemAtPath:preferencesPath error:&error]; [pathsToExclude addObject:[[preferencesPath stringByAppendingString:NSBundle.mainBundle.bundleIdentifier] stringByAppendingString:@".plist"]]; NSString *logPath = [NSHomeDirectory() stringByAppendingString:@"/Library/Caches/Logs/"]; - NSArray *logsFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:logPath error:&error]; + NSArray *logsFiles = [NSFileManager.defaultManager contentsOfDirectoryAtPath:logPath error:&error]; attrs = @{NSFileProtectionKey: NSFileProtectionCompleteUntilFirstUserAuthentication}; - [[NSFileManager defaultManager] setAttributes:attrs ofItemAtPath:logPath error:&error]; + [NSFileManager.defaultManager setAttributes:attrs ofItemAtPath:logPath error:&error]; - for (NSUInteger i = 0; i < logsFiles.count; i++) { - [pathsToExclude addObject:[logPath stringByAppendingString:logsFiles[i]]]; + for (NSString *logsFile in logsFiles) { + [pathsToExclude addObject:[logPath stringByAppendingString:logsFile]]; } - for (NSUInteger i = 0; i < pathsToExclude.count; i++) { - [[NSURL fileURLWithPath:pathsToExclude[i]] setResourceValue:@YES + for (NSString *pathToExclude in pathsToExclude) { + [[NSURL fileURLWithPath:pathToExclude] setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:&error]; } @@ -187,15 +187,15 @@ } - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken { - [[PushManager sharedManager].pushNotificationFutureSource trySetResult:deviceToken]; + [PushManager.sharedManager.pushNotificationFutureSource trySetResult:deviceToken]; } - (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error { - [[PushManager sharedManager].pushNotificationFutureSource trySetFailure:error]; + [PushManager.sharedManager.pushNotificationFutureSource trySetFailure:error]; } - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings{ - [[PushManager sharedManager].userNotificationFutureSource trySetResult:notificationSettings]; + [PushManager.sharedManager.userNotificationFutureSource trySetResult:notificationSettings]; } -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { diff --git a/Signal/src/environment/VersionMigrations.m b/Signal/src/environment/VersionMigrations.m index 616b6395f..2cb5f24d0 100644 --- a/Signal/src/environment/VersionMigrations.m +++ b/Signal/src/environment/VersionMigrations.m @@ -18,7 +18,7 @@ NSString* documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"/Documents/"]; NSString *path = [NSString stringWithFormat:@"%@/%@.plist", documentsDirectory, @"RedPhone-Data"]; - if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { + if ([NSFileManager.defaultManager fileExistsAtPath:path]) { NSData *plistData = [NSData dataWithContentsOfFile:path]; NSError *error; @@ -35,7 +35,7 @@ [defaults synchronize]; - [[NSFileManager defaultManager]removeItemAtPath:path error:&error]; + [NSFileManager.defaultManager removeItemAtPath:path error:&error]; if (error) { DDLogError(@"Error while migrating data: %@", error.description); @@ -49,7 +49,7 @@ DDLogError(@"Error re-registering on migration from 1.0.2"); }]; - [[NSFileManager defaultManager] removeItemAtPath:path error:&error]; + [NSFileManager.defaultManager removeItemAtPath:path error:&error]; if (error) { DDLogError(@"Error upgrading from 1.0.2 : %@", error.description); diff --git a/Signal/src/network/PushManager.m b/Signal/src/network/PushManager.m index f5f96b902..0aa0e16b6 100644 --- a/Signal/src/network/PushManager.m +++ b/Signal/src/network/PushManager.m @@ -9,7 +9,6 @@ #import "PushManager.h" #import "Environment.h" #import "RPServerRequestsManager.h" -#import "FutureUtil.h" @interface PushManager () @@ -26,7 +25,11 @@ static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ sharedManager = [self new]; - sharedManager.missingPermissionsAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"ACTION_REQUIRED_TITLE", @"") message:NSLocalizedString(@"PUSH_SETTINGS_MESSAGE", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", @"") otherButtonTitles:nil, nil]; + sharedManager.missingPermissionsAlertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"ACTION_REQUIRED_TITLE", @"") + message:NSLocalizedString(@"PUSH_SETTINGS_MESSAGE", @"") + delegate:nil + cancelButtonTitle:NSLocalizedString(@"OK", @"") + otherButtonTitles:nil, nil]; }); return sharedManager; } diff --git a/Signal/src/network/http/RPServerRequestsManager.h b/Signal/src/network/http/RPServerRequestsManager.h index 265d74cba..4b48b62b3 100644 --- a/Signal/src/network/http/RPServerRequestsManager.h +++ b/Signal/src/network/http/RPServerRequestsManager.h @@ -15,7 +15,9 @@ MacrosSingletonInterface -- (void)performRequest:(RPAPICall*)apiCall success:(void (^)(NSURLSessionDataTask *task, id responseObject))success failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; +- (void)performRequest:(RPAPICall*)apiCall + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; - (TOCFuture*)futureForRequest:(RPAPICall*)apiCall;