From 792173474053e19500094d4a119a855c847a3c40 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sun, 19 Aug 2012 20:02:23 +0200 Subject: [PATCH] Modernize ObjC syntax. [IMPROVED] Migrate to modern ObjC syntax for type boxing. --- MasterPassword/MPAlgorithm.m | 4 +- MasterPassword/MPAppDelegate_Key.m | 8 +-- MasterPassword/MPAppDelegate_Store.m | 10 ++- MasterPassword/MPConfig.m | 10 ++- MasterPassword/MPEntities.m | 24 ++++--- MasterPassword/iOS/MPAppDelegate.m | 73 +++++++++------------ MasterPassword/iOS/MPGuideViewController.m | 2 +- MasterPassword/iOS/MPMainViewController.m | 65 +++++------------- MasterPassword/iOS/MPSearchDelegate.m | 18 +++-- MasterPassword/iOS/MPUnlockViewController.m | 7 +- MasterPassword/iOS/MPiOSConfig.m | 18 +++-- Tests/Tests.m | 16 ++--- 12 files changed, 100 insertions(+), 155 deletions(-) diff --git a/MasterPassword/MPAlgorithm.m b/MasterPassword/MPAlgorithm.m index 344a1bb9..9f0528d3 100644 --- a/MasterPassword/MPAlgorithm.m +++ b/MasterPassword/MPAlgorithm.m @@ -24,10 +24,10 @@ id MPAlgorithmForVersion(NSUInteger version) { if (!versionToAlgorithm) versionToAlgorithm = [NSMutableDictionary dictionary]; - id algorithm = [versionToAlgorithm objectForKey:PearlUnsignedInteger(version)]; + id algorithm = [versionToAlgorithm objectForKey:@(version)]; if (!algorithm) if ((algorithm = [NSClassFromString(PearlString(@"MPAlgorithmV%u", version)) new])) - [versionToAlgorithm setObject:algorithm forKey:PearlUnsignedInteger(version)]; + [versionToAlgorithm setObject:algorithm forKey:@(version)]; return algorithm; } diff --git a/MasterPassword/MPAppDelegate_Key.m b/MasterPassword/MPAppDelegate_Key.m index ea11453d..45b02955 100644 --- a/MasterPassword/MPAppDelegate_Key.m +++ b/MasterPassword/MPAppDelegate_Key.m @@ -16,10 +16,8 @@ static NSDictionary *keyQuery(MPUserEntity *user) { return [PearlKeyChain createQueryForClass:kSecClassGenericPassword - attributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"Saved Master Password", (__bridge id)kSecAttrService, - user.name, (__bridge id)kSecAttrAccount, - nil] + attributes:@{(__bridge id)kSecAttrService: @"Saved Master Password", + (__bridge id)kSecAttrAccount: user.name} matches:nil]; } @@ -81,7 +79,7 @@ static NSDictionary *keyQuery(MPUserEntity *user) { if (self.activeUser) { self.activeUser = nil; [[NSNotificationCenter defaultCenter] postNotificationName:MPNotificationSignedOut object:self userInfo: - [NSDictionary dictionaryWithObject:PearlBool(animated) forKey:@"animated"]]; + @{@"animated": @(animated)}]; } } diff --git a/MasterPassword/MPAppDelegate_Store.m b/MasterPassword/MPAppDelegate_Store.m index 07a56cc9..90563ea2 100644 --- a/MasterPassword/MPAppDelegate_Store.m +++ b/MasterPassword/MPAppDelegate_Store.m @@ -62,8 +62,7 @@ localStoreURL:[[self applicationFilesDirectory] URLByAppendingPathComponent:@"MasterPassword.sqlite"] containerIdentifier:@"HL3Q45LX9N.com.lyndir.lhunath.MasterPassword.shared" #if TARGET_OS_IPHONE - additionalStoreOptions:[NSDictionary dictionaryWithObject:NSFileProtectionComplete - forKey:NSPersistentStoreFileProtectionKey] + additionalStoreOptions:@{NSPersistentStoreFileProtectionKey: NSFileProtectionComplete} #else additionalStoreOptions:nil #endif @@ -134,10 +133,9 @@ [TestFlight passCheckpoint:iCloudEnabled? MPCheckpointCloudEnabled: MPCheckpointCloudDisabled]; #endif [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointCloud - attributes:[NSDictionary dictionaryWithObject:iCloudEnabled? @"YES": @"NO" - forKey:@"enabled"]]; + attributes:@{@"enabled": iCloudEnabled? @"YES": @"NO"}]; - [MPConfig get].iCloud = [NSNumber numberWithBool:iCloudEnabled]; + [MPConfig get].iCloud = @(iCloudEnabled); } - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didEncounterError:(NSError *)error cause:(UbiquityStoreManagerErrorCause)cause @@ -312,7 +310,7 @@ dbg(@"Existing sites: %@", existingSites); [elementsToDelete addObjectsFromArray:existingSites]; - [importedSiteElements addObject:[NSArray arrayWithObjects:lastUsed, uses, type, version, name, exportContent, nil]]; + [importedSiteElements addObject:@[lastUsed, uses, type, version, name, exportContent]]; } } diff --git a/MasterPassword/MPConfig.m b/MasterPassword/MPConfig.m index 845cb17a..a7cef8ed 100644 --- a/MasterPassword/MPConfig.m +++ b/MasterPassword/MPConfig.m @@ -16,13 +16,11 @@ if (!(self = [super init])) return nil; - [self.defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:YES], NSStringFromSelector(@selector(askForReviews)), + [self.defaults registerDefaults:@{NSStringFromSelector(@selector(askForReviews)): @YES, - [NSNumber numberWithBool:NO], NSStringFromSelector(@selector(rememberLogin)), - [NSNumber numberWithBool:NO], NSStringFromSelector(@selector(iCloud)), - [NSNumber numberWithBool:NO], NSStringFromSelector(@selector(iCloudDecided)), - nil]]; + NSStringFromSelector(@selector(rememberLogin)): @NO, + NSStringFromSelector(@selector(iCloud)): @NO, + NSStringFromSelector(@selector(iCloudDecided)): @NO}]; self.delegate = [MPAppDelegate get]; diff --git a/MasterPassword/MPEntities.m b/MasterPassword/MPEntities.m index c796194c..b5a8066b 100644 --- a/MasterPassword/MPEntities.m +++ b/MasterPassword/MPEntities.m @@ -18,7 +18,7 @@ - (void)setType:(MPElementType)aType { - self.type_ = PearlUnsignedInteger(aType); + self.type_ = @(aType); } - (NSString *)typeName { @@ -48,7 +48,7 @@ - (void)setUses:(NSUInteger)anUses { - self.uses_ = PearlUnsignedInteger(anUses); + self.uses_ = @(anUses); } - (NSUInteger)version { @@ -58,7 +58,7 @@ - (void)setVersion:(NSUInteger)version { - self.version_ = PearlUnsignedInteger(version); + self.version_ = @(version); } - (BOOL)requiresExplicitMigration { @@ -68,7 +68,7 @@ - (void)setRequiresExplicitMigration:(BOOL)requiresExplicitMigration { - self.requiresExplicitMigration_ = PearlBool(requiresExplicitMigration); + self.requiresExplicitMigration_ = @(requiresExplicitMigration); } - (id)algorithm { @@ -136,7 +136,7 @@ - (void)setCounter:(NSUInteger)aCounter { - self.counter_ = PearlUnsignedInteger(aCounter); + self.counter_ = @(aCounter); } - (id)content { @@ -163,10 +163,8 @@ + (NSDictionary *)queryForDevicePrivateElementNamed:(NSString *)name { return [PearlKeyChain createQueryForClass:kSecClassGenericPassword - attributes:[NSDictionary dictionaryWithObjectsAndKeys: - @"DevicePrivate", (__bridge id)kSecAttrService, - name, (__bridge id)kSecAttrAccount, - nil] + attributes:@{(__bridge id)kSecAttrService: @"DevicePrivate", + (__bridge id)kSecAttrAccount: name} matches:nil]; } @@ -268,7 +266,7 @@ - (void)setAvatar:(NSUInteger)anAvatar { - self.avatar_ = PearlUnsignedInteger(anAvatar); + self.avatar_ = @(anAvatar); } - (BOOL)saveKey { @@ -278,7 +276,7 @@ - (void)setSaveKey:(BOOL)aSaveKey { - self.saveKey_ = [NSNumber numberWithBool:aSaveKey]; + self.saveKey_ = @(aSaveKey); } - (MPElementType)defaultType { @@ -288,7 +286,7 @@ - (void)setDefaultType:(MPElementType)aDefaultType { - self.defaultType_ = PearlUnsignedInteger(aDefaultType); + self.defaultType_ = @(aDefaultType); } - (BOOL)requiresExplicitMigration { @@ -298,7 +296,7 @@ - (void)setRequiresExplicitMigration:(BOOL)requiresExplicitMigration { - self.requiresExplicitMigration_ = PearlBool(requiresExplicitMigration); + self.requiresExplicitMigration_ = @(requiresExplicitMigration); } - (NSString *)userID { diff --git a/MasterPassword/iOS/MPAppDelegate.m b/MasterPassword/iOS/MPAppDelegate.m index c6e30d63..8c440612 100644 --- a/MasterPassword/iOS/MPAppDelegate.m +++ b/MasterPassword/iOS/MPAppDelegate.m @@ -115,12 +115,8 @@ [[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) { if (message.level >= PearlLogLevelWarn) [[LocalyticsSession sharedLocalyticsSession] tagEvent:@"Problem" - attributes:[NSDictionary - dictionaryWithObjectsAndKeys: - [NSString stringWithCString:PearlLogLevelStr(message.level) - encoding:NSASCIIStringEncoding], @"level", - message.message, @"message", - nil]]; + attributes:@{@"level": @(PearlLogLevelStr(message.level)), + @"message": message.message}]; return YES; }]; @@ -134,12 +130,10 @@ [[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setBackgroundImage:navBarImage forBarMetrics:UIBarMetricsLandscapePhone]; [[UINavigationBar appearance] setTitleTextAttributes: - [NSDictionary dictionaryWithObjectsAndKeys: - [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f], UITextAttributeTextColor, - [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.8f], UITextAttributeTextShadowColor, - [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], UITextAttributeTextShadowOffset, - [UIFont fontWithName:@"Exo-Bold" size:20.0f], UITextAttributeFont, - nil]]; + @{UITextAttributeTextColor: [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f], + UITextAttributeTextShadowColor: [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.8f], + UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, -1)], + UITextAttributeFont: [UIFont fontWithName:@"Exo-Bold" size:20.0f]}]; UIImage *navBarButton = [[UIImage imageNamed:@"ui_navbar_button"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 5, 0, 5)]; UIImage *navBarBack = [[UIImage imageNamed:@"ui_navbar_back"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 13, 0, 5)]; @@ -148,12 +142,10 @@ [[UIBarButtonItem appearance] setBackButtonBackgroundImage:navBarBack forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; [[UIBarButtonItem appearance] setBackButtonBackgroundImage:nil forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone]; [[UIBarButtonItem appearance] setTitleTextAttributes: - [NSDictionary dictionaryWithObjectsAndKeys: - [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f], UITextAttributeTextColor, - [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.5f], UITextAttributeTextShadowColor, - [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, - [UIFont fontWithName:@"Helvetica-Neue" size:0.0f], UITextAttributeFont, - nil] + @{UITextAttributeTextColor: [UIColor colorWithRed:1.0f green:1.0f blue:1.0f alpha:1.0f], + UITextAttributeTextShadowColor: [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.5f], + UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], + UITextAttributeFont: [UIFont fontWithName:@"Helvetica-Neue" size:0.0f]} forState:UIControlStateNormal]; UIImage *toolBarImage = [[UIImage imageNamed:@"ui_toolbar_container"] resizableImageWithCapInsets:UIEdgeInsetsMake(25, 5, 5, 5)]; @@ -408,30 +400,25 @@ [TestFlight passCheckpoint:MPCheckpointConfig]; [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointConfig attributes: - [NSDictionary dictionaryWithObjectsAndKeys: - [[MPConfig get].rememberLogin boolValue] - ? @"YES": @"NO", @"rememberLogin", - [[MPConfig get].iCloud boolValue]? @"YES" - : @"NO", @"iCloud", - [[MPConfig get].iCloudDecided boolValue] - ? @"YES": @"NO", @"iCloudDecided", - [[MPiOSConfig get].sendInfo boolValue] - ? @"YES": @"NO", @"sendInfo", - [[MPiOSConfig get].helpHidden boolValue] - ? @"YES": @"NO", @"helpHidden", - [[MPiOSConfig get].showQuickStart boolValue] - ? @"YES": @"NO", @"showQuickStart", - [[PearlConfig get].firstRun boolValue] - ? @"YES": @"NO", @"firstRun", - [[PearlConfig get].launchCount description], - @"launchCount", - [[PearlConfig get].askForReviews boolValue] - ? @"YES": @"NO", @"askForReviews", - [[PearlConfig get].reviewAfterLaunches description], - @"reviewAfterLaunches", - [PearlConfig get].reviewedVersion, - @"reviewedVersion", - nil]]; + @{@"rememberLogin": [[MPConfig get].rememberLogin boolValue] + ? @"YES": @"NO", + @"iCloud": [[MPConfig get].iCloud boolValue]? @"YES" + : @"NO", + @"iCloudDecided": [[MPConfig get].iCloudDecided boolValue] + ? @"YES": @"NO", + @"sendInfo": [[MPiOSConfig get].sendInfo boolValue] + ? @"YES": @"NO", + @"helpHidden": [[MPiOSConfig get].helpHidden boolValue] + ? @"YES": @"NO", + @"showQuickStart": [[MPiOSConfig get].showQuickStart boolValue] + ? @"YES": @"NO", + @"firstRun": [[PearlConfig get].firstRun boolValue] + ? @"YES": @"NO", + @"launchCount": [[PearlConfig get].launchCount description], + @"askForReviews": [[PearlConfig get].askForReviews boolValue] + ? @"YES": @"NO", + @"reviewAfterLaunches": [[PearlConfig get].reviewAfterLaunches description], + @"reviewedVersion": [PearlConfig get].reviewedVersion}]; } } @@ -613,7 +600,7 @@ return; } - [MPConfig get].iCloudDecided = [NSNumber numberWithBool:YES]; + [MPConfig get].iCloudDecided = @YES; if (buttonIndex == [alert cancelButtonIndex]) return; if (buttonIndex == [alert firstOtherButtonIndex] + 1) diff --git a/MasterPassword/iOS/MPGuideViewController.m b/MasterPassword/iOS/MPGuideViewController.m index 949a9263..dc2fe5ea 100644 --- a/MasterPassword/iOS/MPGuideViewController.m +++ b/MasterPassword/iOS/MPGuideViewController.m @@ -43,7 +43,7 @@ inf(@"Guide will disappear."); [super viewWillDisappear:animated]; - [MPiOSConfig get].showQuickStart = [NSNumber numberWithBool:NO]; + [MPiOSConfig get].showQuickStart = @NO; } - (void)viewDidUnload { diff --git a/MasterPassword/iOS/MPMainViewController.m b/MasterPassword/iOS/MPMainViewController.m index d51d324f..90c2ccf2 100644 --- a/MasterPassword/iOS/MPMainViewController.m +++ b/MasterPassword/iOS/MPMainViewController.m @@ -303,7 +303,7 @@ - (void)setHelpHidden:(BOOL)hidden animated:(BOOL)animated { - [MPiOSConfig get].helpHidden = PearlBool(hidden); + [MPiOSConfig get].helpHidden = @(hidden); [self updateHelpHiddenAnimated:animated]; } @@ -481,11 +481,8 @@ [TestFlight passCheckpoint:MPCheckpointCopyToPasteboard]; [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointCopyToPasteboard - attributes:[NSDictionary dictionaryWithObjectsAndKeys: - self.activeElement.typeName, @"type", - PearlUnsignedInteger(self.activeElement.version), - @"version", - nil]]; + attributes:@{@"type": self.activeElement.typeName, + @"version": @(self.activeElement.version)}]; } - (IBAction)copyLoginName:(UITapGestureRecognizer *)sender { @@ -500,11 +497,8 @@ [TestFlight passCheckpoint:MPCheckpointCopyLoginNameToPasteboard]; [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointCopyLoginNameToPasteboard - attributes:[NSDictionary dictionaryWithObjectsAndKeys: - self.activeElement.typeName, @"type", - PearlUnsignedInteger(self.activeElement.version), - @"version", - nil]]; + attributes:@{@"type": self.activeElement.typeName, + @"version": @(self.activeElement.version)}]; } - (IBAction)incrementPasswordCounter { @@ -524,12 +518,8 @@ [TestFlight passCheckpoint:MPCheckpointIncrementPasswordCounter]; [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointIncrementPasswordCounter - attributes:[NSDictionary dictionaryWithObjectsAndKeys: - self.activeElement.typeName, - @"type", - PearlUnsignedInteger(self.activeElement.version), - @"version", - nil]]; + attributes:@{@"type": self.activeElement.typeName, + @"version": @(self.activeElement.version)}]; }]; } @@ -555,12 +545,8 @@ [TestFlight passCheckpoint:MPCheckpointResetPasswordCounter]; [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointResetPasswordCounter - attributes:[NSDictionary dictionaryWithObjectsAndKeys: - self.activeElement.typeName, - @"type", - PearlUnsignedInteger(self.activeElement.version), - @"version", - nil]]; + attributes:@{@"type": self.activeElement.typeName, + @"version": @(self.activeElement.version)}]; }]; } @@ -577,12 +563,8 @@ [self.loginNameField becomeFirstResponder]; [TestFlight passCheckpoint:MPCheckpointEditLoginName]; - [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointEditLoginName attributes:[NSDictionary dictionaryWithObjectsAndKeys: - self.activeElement.typeName, - @"type", - PearlUnsignedInteger(self.activeElement.version), - @"version", - nil]]; + [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointEditLoginName attributes:@{@"type": self.activeElement.typeName, + @"version": @(self.activeElement.version)}]; } - (void)changeElementWithWarning:(NSString *)warning do:(void (^)(void))task; { @@ -624,11 +606,8 @@ [TestFlight passCheckpoint:MPCheckpointEditPassword]; [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointEditPassword - attributes:[NSDictionary dictionaryWithObjectsAndKeys: - self.activeElement.typeName, @"type", - PearlUnsignedInteger(self.activeElement.version), - @"version", - nil]]; + attributes:@{@"type": self.activeElement.typeName, + @"version": @(self.activeElement.version)}]; } } @@ -648,12 +627,8 @@ [TestFlight passCheckpoint:MPCheckpointExplicitMigration]; [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointExplicitMigration - attributes:[NSDictionary dictionaryWithObjectsAndKeys: - self.activeElement.typeName, - @"type", - PearlUnsignedInteger(self.activeElement.version), - @"version", - nil]]; + attributes:@{@"type": self.activeElement.typeName, + @"version": @(self.activeElement.version)}]; }]; } @@ -753,7 +728,7 @@ initAlert:nil tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) { MFMailComposeViewController *composer = [MFMailComposeViewController new]; [composer setMailComposeDelegate:self]; - [composer setToRecipients:[NSArray arrayWithObject:@"Master Password Development "]]; + [composer setToRecipients:@[@"Master Password Development "]]; [composer setSubject:PearlString(@"Feedback for Master Password [%@]", [[PearlKeyChain deviceIdentifier] stringByDeletingMatchesOf:@"-.*"])]; [composer setMessageBody: @@ -885,12 +860,8 @@ [[NSNotificationCenter defaultCenter] postNotificationName:MPNotificationElementUpdated object:self.activeElement]; [TestFlight passCheckpoint:PearlString(MPCheckpointUseType @"_%@", self.activeElement.typeShortName)]; - [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointUseType attributes:[NSDictionary dictionaryWithObjectsAndKeys: - self.activeElement.typeName, - @"type", - PearlUnsignedInteger(self.activeElement.version), - @"version", - nil]]; + [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointUseType attributes:@{@"type": self.activeElement.typeName, + @"version": @(self.activeElement.version)}]; } [self.searchDisplayController setActive:NO animated:YES]; diff --git a/MasterPassword/iOS/MPSearchDelegate.m b/MasterPassword/iOS/MPSearchDelegate.m index 2b2d3354..cb0d068b 100644 --- a/MasterPassword/iOS/MPSearchDelegate.m +++ b/MasterPassword/iOS/MPSearchDelegate.m @@ -65,7 +65,7 @@ return nil; NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([MPElementEntity class])]; - fetchRequest.sortDescriptors = [NSArray arrayWithObject:[[NSSortDescriptor alloc] initWithKey:@"uses_" ascending:NO]]; + fetchRequest.sortDescriptors = @[[[NSSortDescriptor alloc] initWithKey:@"uses_" ascending:NO]]; _fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:moc sectionNameKeyPath:nil cacheName:nil]; _fetchedResultsController.delegate = self; @@ -110,7 +110,7 @@ controller.searchBar.prompt = @"Enter the site's name:"; controller.searchBar.showsScopeBar = controller.searchBar.selectedScopeButtonIndex != MPSearchScopeAll; if (controller.searchBar.showsScopeBar) - controller.searchBar.scopeButtonTitles = [NSArray arrayWithObjects:@"All", @"Outdated", nil]; + controller.searchBar.scopeButtonTitles = @[@"All", @"Outdated"]; else controller.searchBar.scopeButtonTitles = nil; @@ -168,8 +168,8 @@ NSPredicate *predicate = [NSPredicate predicateWithFormat:@"user == %@", [MPAppDelegate get].activeUser]; if (self.query.length) predicate = [NSCompoundPredicate - andPredicateWithSubpredicates:[NSArray arrayWithObjects:[NSPredicate predicateWithFormat:@"name BEGINSWITH[cd] %@", self.query], - predicate, nil]]; + andPredicateWithSubpredicates:@[[NSPredicate predicateWithFormat:@"name BEGINSWITH[cd] %@", self.query], + predicate]]; switch ((MPSearchScope)self.searchDisplayController.searchBar.selectedScopeButtonIndex) { @@ -177,8 +177,8 @@ break; case MPSearchScopeOutdated: predicate = [NSCompoundPredicate - andPredicateWithSubpredicates:[NSArray arrayWithObjects:[NSPredicate predicateWithFormat:@"requiresExplicitMigration_ == YES"], - predicate, nil]]; + andPredicateWithSubpredicates:@[[NSPredicate predicateWithFormat:@"requiresExplicitMigration_ == YES"], + predicate]]; break; } self.fetchedResultsController.fetchRequest.predicate = predicate; @@ -405,10 +405,8 @@ forRowAtIndexPath:(NSIndexPath *)indexPath { [TestFlight passCheckpoint:MPCheckpointDeleteElement]; [[LocalyticsSession sharedLocalyticsSession] tagEvent:MPCheckpointDeleteElement - attributes:[NSDictionary dictionaryWithObjectsAndKeys: - element.typeName, @"type", - PearlUnsignedInteger(element.version), @"version", - nil]]; + attributes:@{@"type": element.typeName, + @"version": @(element.version)}]; }]; } } diff --git a/MasterPassword/iOS/MPUnlockViewController.m b/MasterPassword/iOS/MPUnlockViewController.m index 2709bbd2..0b52e37b 100644 --- a/MasterPassword/iOS/MPUnlockViewController.m +++ b/MasterPassword/iOS/MPUnlockViewController.m @@ -222,7 +222,7 @@ [moc performBlockAndWait:^{ NSError *error = nil; NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([MPUserEntity class])]; - fetchRequest.sortDescriptors = [NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"lastUsed" ascending:NO]]; + fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"lastUsed" ascending:NO]]; users = [moc executeFetchRequest:fetchRequest error:&error]; if (!users) err(@"Failed to load users: %@", error); @@ -633,8 +633,7 @@ pulseShadowOpacityAnimation.repeatCount = MAXFLOAT; CAAnimationGroup *group = [[CAAnimationGroup alloc] init]; - group.animations = [NSArray arrayWithObjects:toShadowColorAnimation, toShadowOpacityAnimation, pulseShadowOpacityAnimation, - nil]; + group.animations = @[toShadowColorAnimation, toShadowOpacityAnimation, pulseShadowOpacityAnimation]; group.duration = MAXFLOAT; [avatar.layer removeAnimationForKey:@"inactiveShadow"]; @@ -651,7 +650,7 @@ toShadowOpacityAnimation.duration = 0.5f; CAAnimationGroup *group = [[CAAnimationGroup alloc] init]; - group.animations = [NSArray arrayWithObjects:toShadowColorAnimation, toShadowOpacityAnimation, nil]; + group.animations = @[toShadowColorAnimation, toShadowOpacityAnimation]; group.duration = 0.5f; [avatar.layer removeAnimationForKey:@"targetedShadow"]; diff --git a/MasterPassword/iOS/MPiOSConfig.m b/MasterPassword/iOS/MPiOSConfig.m index 239d95ce..83ce286f 100644 --- a/MasterPassword/iOS/MPiOSConfig.m +++ b/MasterPassword/iOS/MPiOSConfig.m @@ -14,16 +14,14 @@ if (!(self = [super init])) return self; - [self.defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:NO], NSStringFromSelector(@selector(sendInfo)), - [NSNumber numberWithBool:NO], NSStringFromSelector(@selector(helpHidden)), - [NSNumber numberWithBool:YES], NSStringFromSelector(@selector(siteInfoHidden)), - [NSNumber numberWithBool:YES], NSStringFromSelector(@selector(showQuickStart)), - @"510296984", NSStringFromSelector(@selector(iTunesID)), - PearlBoolNot(self.firstRun), NSStringFromSelector(@selector(actionsTipShown)), - PearlBoolNot(self.firstRun), NSStringFromSelector(@selector(typeTipShown)), - PearlBool(NO), NSStringFromSelector(@selector(loginNameTipShown)), - nil]]; + [self.defaults registerDefaults:@{NSStringFromSelector(@selector(sendInfo)): @NO, + NSStringFromSelector(@selector(helpHidden)): @NO, + NSStringFromSelector(@selector(siteInfoHidden)): @YES, + NSStringFromSelector(@selector(showQuickStart)): @YES, + NSStringFromSelector(@selector(iTunesID)): @"510296984", + NSStringFromSelector(@selector(actionsTipShown)): PearlBoolNot(self.firstRun), + NSStringFromSelector(@selector(typeTipShown)): PearlBoolNot(self.firstRun), + NSStringFromSelector(@selector(loginNameTipShown)): PearlBool(NO)}]; return self; } diff --git a/Tests/Tests.m b/Tests/Tests.m index e2b0d02c..377b08d2 100644 --- a/Tests/Tests.m +++ b/Tests/Tests.m @@ -30,16 +30,16 @@ - (void)testAlgorithm { - NSString *masterPassword = @"test-mp"; - NSString *username = @"test-user"; - NSString *siteName = @"test-site"; - MPElementType siteType = MPElementTypeGeneratedLong; - uint32_t siteCounter = 42; + //NSString *masterPassword = @"test-mp"; + //NSString *username = @"test-user"; + //NSString *siteName = @"test-site"; + //MPElementType siteType = MPElementTypeGeneratedLong; + //uint32_t siteCounter = 42; - NSString *sitePassword = MPCalculateContent( siteType, siteName, keyForPassword( masterPassword, username ), siteCounter ); + //NSString *sitePassword = MPCalculateContent( siteType, siteName, keyForPassword( masterPassword, username ), siteCounter ); - inf( @"master password: %@, username: %@\nsite name: %@, site type: %@, site counter: %d\n => site password: %@", - masterPassword, username, siteName, NSStringFromMPElementType(siteType), siteCounter, sitePassword ); + //inf( @"master password: %@, username: %@\nsite name: %@, site type: %@, site counter: %d\n => site password: %@", + // masterPassword, username, siteName, NSStringFromMPElementType(siteType), siteCounter, sitePassword ); } @end