2
0

Modernized Obj-C syntax.

[UPDATED]   Modernized Obj-C syntax.
This commit is contained in:
Maarten Billemont 2013-09-27 21:23:52 -04:00
parent 14e34e8e7a
commit b67132671a
12 changed files with 35 additions and 35 deletions

2
External/Pearl vendored

@ -1 +1 @@
Subproject commit 00b732f8b73035b81c4abd763ee2a7e54f6ad3c5 Subproject commit fb1b46e2b4f2e661f84521ce243d31a10aa9cee7

@ -1 +1 @@
Subproject commit 7fb753f0f84afdb5607332b586f1345d9a2ae1a1 Subproject commit 4834f69d55b7cd84d719869336ba213ecc456542

View File

@ -23,9 +23,9 @@ id<MPAlgorithm> MPAlgorithmForVersion(NSUInteger version) {
if (!versionToAlgorithm) if (!versionToAlgorithm)
versionToAlgorithm = [NSMutableDictionary dictionary]; versionToAlgorithm = [NSMutableDictionary dictionary];
id<MPAlgorithm> algorithm = [versionToAlgorithm objectForKey:@(version)]; id<MPAlgorithm> algorithm = versionToAlgorithm[@(version)];
if (!algorithm) if ((algorithm = [NSClassFromString( PearlString( @"MPAlgorithmV%lu", (unsigned long)version ) ) new])) if (!algorithm) if ((algorithm = [NSClassFromString( PearlString( @"MPAlgorithmV%lu", (unsigned long)version ) ) new]))
[versionToAlgorithm setObject:algorithm forKey:@(version)]; versionToAlgorithm[@(version)] = algorithm;
return algorithm; return algorithm;
} }

View File

@ -229,7 +229,7 @@
NSAssert([seed length], @"Missing seed."); NSAssert([seed length], @"Missing seed.");
NSArray *typeCiphers = [[MPTypes_ciphers valueForKey:[self classNameOfType:type]] NSArray *typeCiphers = [[MPTypes_ciphers valueForKey:[self classNameOfType:type]]
valueForKey:[self nameOfType:type]]; valueForKey:[self nameOfType:type]];
NSString *cipher = [typeCiphers objectAtIndex:htons(seedBytes[0]) % [typeCiphers count]]; NSString *cipher = typeCiphers[htons(seedBytes[0]) % [typeCiphers count]];
trc(@"type %@, ciphers: %@, selected: %@", [self nameOfType:type], typeCiphers, cipher); trc(@"type %@, ciphers: %@, selected: %@", [self nameOfType:type], typeCiphers, cipher);
// Encode the content, character by character, using subsequent seed bytes and the cipher. // Encode the content, character by character, using subsequent seed bytes and the cipher.

View File

@ -70,7 +70,7 @@
// Determine the cipher from the first seed byte. // Determine the cipher from the first seed byte.
NSAssert([seed length], @"Missing seed."); NSAssert([seed length], @"Missing seed.");
NSArray *typeCiphers = [[MPTypes_ciphers valueForKey:[self classNameOfType:type]] valueForKey:[self nameOfType:type]]; NSArray *typeCiphers = [[MPTypes_ciphers valueForKey:[self classNameOfType:type]] valueForKey:[self nameOfType:type]];
NSString *cipher = [typeCiphers objectAtIndex:seedBytes[0] % [typeCiphers count]]; NSString *cipher = typeCiphers[seedBytes[0] % [typeCiphers count]];
trc(@"type %@, ciphers: %@, selected: %@", [self nameOfType:type], typeCiphers, cipher); trc(@"type %@, ciphers: %@, selected: %@", [self nameOfType:type], typeCiphers, cipher);
// Encode the content, character by character, using subsequent seed bytes and the cipher. // Encode the content, character by character, using subsequent seed bytes and the cipher.

View File

@ -608,12 +608,12 @@ PearlAssociatedObjectProperty(NSManagedObjectContext*, MainManagedObjectContext,
// Import new sites. // Import new sites.
for (NSArray *siteElements in importedSiteElements) { for (NSArray *siteElements in importedSiteElements) {
NSDate *lastUsed = [[NSDateFormatter rfc3339DateFormatter] dateFromString:[siteElements objectAtIndex:0]]; NSDate *lastUsed = [[NSDateFormatter rfc3339DateFormatter] dateFromString:siteElements[0]];
NSUInteger uses = (unsigned)[[siteElements objectAtIndex:1] integerValue]; NSUInteger uses = (unsigned)[siteElements[1] integerValue];
MPElementType type = (MPElementType)[[siteElements objectAtIndex:2] integerValue]; MPElementType type = (MPElementType)[siteElements[2] integerValue];
NSUInteger version = (unsigned)[[siteElements objectAtIndex:3] integerValue]; NSUInteger version = (unsigned)[siteElements[3] integerValue];
NSString *name = [siteElements objectAtIndex:4]; NSString *name = siteElements[4];
NSString *exportContent = [siteElements objectAtIndex:5]; NSString *exportContent = siteElements[5];
// Create new site. // Create new site.
MPElementEntity MPElementEntity

View File

@ -64,7 +64,7 @@
[UIApp setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; [UIApp setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
MPCheckpoint( MPCheckpointApps, nil ); MPCheckpoint( MPCheckpointApps, nil );
[self.pageViewController setViewControllers:@[ [self.pageVCs objectAtIndex:1] ] direction:UIPageViewControllerNavigationDirectionForward [self.pageViewController setViewControllers:@[ (self.pageVCs)[1] ] direction:UIPageViewControllerNavigationDirectionForward
animated:NO completion:nil]; animated:NO completion:nil];
[super viewWillAppear:animated]; [super viewWillAppear:animated];
@ -76,7 +76,7 @@
[[LocalyticsSession sharedLocalyticsSession] tagScreen:@"Apps"]; [[LocalyticsSession sharedLocalyticsSession] tagScreen:@"Apps"];
#endif #endif
[self.pageViewController setViewControllers:@[ [self.pageVCs objectAtIndex:0] ] direction:UIPageViewControllerNavigationDirectionForward [self.pageViewController setViewControllers:@[ (self.pageVCs)[0] ] direction:UIPageViewControllerNavigationDirectionForward
animated:YES completion:nil]; animated:YES completion:nil];
[super viewDidAppear:animated]; [super viewDidAppear:animated];
@ -103,14 +103,14 @@
viewControllerBeforeViewController:(UIViewController *)viewController { viewControllerBeforeViewController:(UIViewController *)viewController {
NSUInteger vcIndex = [self.pageVCs indexOfObject:viewController]; NSUInteger vcIndex = [self.pageVCs indexOfObject:viewController];
return [self.pageVCs objectAtIndex:(vcIndex + [self.pageVCs count] - 1) % self.pageVCs.count]; return (self.pageVCs)[(vcIndex + [self.pageVCs count] - 1) % self.pageVCs.count];
} }
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController
viewControllerAfterViewController:(UIViewController *)viewController { viewControllerAfterViewController:(UIViewController *)viewController {
NSUInteger vcIndex = [self.pageVCs indexOfObject:viewController]; NSUInteger vcIndex = [self.pageVCs indexOfObject:viewController];
return [self.pageVCs objectAtIndex:(vcIndex + 1) % self.pageVCs.count]; return (self.pageVCs)[(vcIndex + 1) % self.pageVCs.count];
} }
- (IBAction)exit { - (IBAction)exit {

View File

@ -117,10 +117,10 @@
id newContent = [element.algorithm resolveContentForElement:element usingKey:key]; id newContent = [element.algorithm resolveContentForElement:element usingKey:key];
if (!(element.type & MPElementFeatureDevicePrivate) && (!oldContent || ![oldContent isEqual:newContent])) if (!(element.type & MPElementFeatureDevicePrivate) && (!oldContent || ![oldContent isEqual:newContent]))
[elementChanges setObject:@{ elementChanges[element.name] = @{
MPElementUpgradeOldContentKey : oldContent, MPElementUpgradeOldContentKey : oldContent,
MPElementUpgradeNewContentKey : newContent, MPElementUpgradeNewContentKey : newContent,
} forKey:element.name]; };
} }
[moc saveToStore]; [moc saveToStore];
@ -135,9 +135,9 @@
NSMutableString *formattedChanges = [NSMutableString new]; NSMutableString *formattedChanges = [NSMutableString new];
for (NSString *changedElementName in changes) { for (NSString *changedElementName in changes) {
NSDictionary *elementChanges = [changes objectForKey:changedElementName]; NSDictionary *elementChanges = changes[changedElementName];
id oldContent = [elementChanges objectForKey:MPElementUpgradeOldContentKey]; id oldContent = elementChanges[MPElementUpgradeOldContentKey];
id newContent = [elementChanges objectForKey:MPElementUpgradeNewContentKey]; id newContent = elementChanges[MPElementUpgradeNewContentKey];
[formattedChanges appendFormat:@"%@: %@ -> %@\n", changedElementName, oldContent, newContent]; [formattedChanges appendFormat:@"%@: %@ -> %@\n", changedElementName, oldContent, newContent];
} }

View File

@ -88,7 +88,7 @@
NSFetchRequest *sitesFetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPElementEntity class] )]; NSFetchRequest *sitesFetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPElementEntity class] )];
for (NSURL *cloudStoreURL in cloudStores) { for (NSURL *cloudStoreURL in cloudStores) {
NSString *storeUUID = [[cloudStoreURL URLByDeletingPathExtension] lastPathComponent]; NSString *storeUUID = [[cloudStoreURL URLByDeletingPathExtension] lastPathComponent];
for (NSDictionary *cloudStoreOptions in [cloudStores objectForKey:cloudStoreURL]) { for (NSDictionary *cloudStoreOptions in cloudStores[cloudStoreURL]) {
NSError *error = nil; NSError *error = nil;
NSPersistentStore *store = nil; NSPersistentStore *store = nil;
NSUInteger firstDash = [storeUUID rangeOfString:@"-" options:0].location; NSUInteger firstDash = [storeUUID rangeOfString:@"-" options:0].location;
@ -127,7 +127,7 @@
storePSC = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; storePSC = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
} }
[stores setObject:cloudStoreOptions forKey:storeDescription]; stores[storeDescription] = cloudStoreOptions;
} }
} }
} }

View File

@ -94,7 +94,7 @@
[[NSNotificationCenter defaultCenter] addObserverForName:MPSignedOutNotification object:nil [[NSNotificationCenter defaultCenter] addObserverForName:MPSignedOutNotification object:nil
queue:[NSOperationQueue mainQueue] usingBlock: queue:[NSOperationQueue mainQueue] usingBlock:
^(NSNotification *note) { ^(NSNotification *note) {
BOOL animated = [[note.userInfo objectForKey:@"animated"] boolValue]; BOOL animated = [(note.userInfo)[@"animated"] boolValue];
_activeElementOID = nil; _activeElementOID = nil;
self.suppressOutdatedAlert = NO; self.suppressOutdatedAlert = NO;
@ -294,7 +294,7 @@
- (void)toggleUserAnimated:(BOOL)animated { - (void)toggleUserAnimated:(BOOL)animated {
[MPiOSConfig get].siteInfoHidden = PearlBool(!self.siteInfoHidden); [MPiOSConfig get].siteInfoHidden = @(!self.siteInfoHidden);
self.siteInfoHidden = [[MPiOSConfig get].siteInfoHidden boolValue]; self.siteInfoHidden = [[MPiOSConfig get].siteInfoHidden boolValue];
[self updateUserHiddenAnimated:animated]; [self updateUserHiddenAnimated:animated];
} }

View File

@ -365,7 +365,7 @@
} options:0]; } options:0];
[self.avatarToUserOID setObject:NilToNSNull([user objectID]) forKey:[NSValue valueWithNonretainedObject:avatar]]; (self.avatarToUserOID)[[NSValue valueWithNonretainedObject:avatar]] = NilToNSNull([user objectID]);
if ([_selectedUserOID isEqual:[user objectID]]) if ([_selectedUserOID isEqual:[user objectID]])
avatar.selected = YES; avatar.selected = YES;
@ -625,7 +625,7 @@
- (void)initializeWordLabel:(UILabel *)wordLabel { - (void)initializeWordLabel:(UILabel *)wordLabel {
wordLabel.alpha = 0.05 + (random() % 35) / 100.0F; wordLabel.alpha = 0.05 + (random() % 35) / 100.0F;
wordLabel.text = [self.wordList objectAtIndex:(NSUInteger)random() % [self.wordList count]]; wordLabel.text = (self.wordList)[(NSUInteger)random() % [self.wordList count]];
} }
- (void)setPasswordTip:(NSString *)string { - (void)setPasswordTip:(NSString *)string {
@ -686,7 +686,7 @@
- (MPUserEntity *)userForAvatar:(UIButton *)avatar inContext:(NSManagedObjectContext *)context { - (MPUserEntity *)userForAvatar:(UIButton *)avatar inContext:(NSManagedObjectContext *)context {
NSManagedObjectID *userOID = NSNullToNil([self.avatarToUserOID objectForKey:[NSValue valueWithNonretainedObject:avatar]]); NSManagedObjectID *userOID = NSNullToNil((self.avatarToUserOID)[[NSValue valueWithNonretainedObject:avatar]]);
if (!userOID) if (!userOID)
return nil; return nil;
@ -707,7 +707,7 @@
if (active) { if (active) {
rotate.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; rotate.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
rotate.fromValue = [NSNumber numberWithFloat:0]; rotate.fromValue = @0.0;
rotate.repeatCount = MAXFLOAT; rotate.repeatCount = MAXFLOAT;
} }
else { else {
@ -741,12 +741,12 @@
toShadowColorAnimation.fillMode = kCAFillModeForwards; toShadowColorAnimation.fillMode = kCAFillModeForwards;
CABasicAnimation *toShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"]; CABasicAnimation *toShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
toShadowOpacityAnimation.toValue = PearlFloat(0.2); toShadowOpacityAnimation.toValue = @0.2f;
toShadowOpacityAnimation.duration = 0.5f; toShadowOpacityAnimation.duration = 0.5f;
CABasicAnimation *pulseShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"]; CABasicAnimation *pulseShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
pulseShadowOpacityAnimation.fromValue = PearlFloat(0.2); pulseShadowOpacityAnimation.fromValue = @0.2f;
pulseShadowOpacityAnimation.toValue = PearlFloat(0.6); pulseShadowOpacityAnimation.toValue = @0.6f;
pulseShadowOpacityAnimation.beginTime = 0.5f; pulseShadowOpacityAnimation.beginTime = 0.5f;
pulseShadowOpacityAnimation.duration = 2.0f; pulseShadowOpacityAnimation.duration = 2.0f;
pulseShadowOpacityAnimation.autoreverses = YES; pulseShadowOpacityAnimation.autoreverses = YES;
@ -767,7 +767,7 @@
toShadowColorAnimation.duration = 0.5f; toShadowColorAnimation.duration = 0.5f;
CABasicAnimation *toShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"]; CABasicAnimation *toShadowOpacityAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
toShadowOpacityAnimation.toValue = PearlFloat(1); toShadowOpacityAnimation.toValue = @1.0f;
toShadowOpacityAnimation.duration = 0.5f; toShadowOpacityAnimation.duration = 0.5f;
CAAnimationGroup *group = [[CAAnimationGroup alloc] init]; CAAnimationGroup *group = [[CAAnimationGroup alloc] init];

View File

@ -33,8 +33,8 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
@try { @try {
[[[NSBundle mainBundle] mutableInfoDictionary] setObject:@"Master Password" forKey:@"CFBundleDisplayName"]; [[NSBundle mainBundle] mutableInfoDictionary][@"CFBundleDisplayName"] = @"Master Password";
[[[NSBundle mainBundle] mutableLocalizedInfoDictionary] setObject:@"Master Password" forKey:@"CFBundleDisplayName"]; [[NSBundle mainBundle] mutableLocalizedInfoDictionary][@"CFBundleDisplayName"] = @"Master Password";
#ifdef TESTFLIGHT_SDK_VERSION #ifdef TESTFLIGHT_SDK_VERSION
NSString *testFlightToken = [self testFlightToken]; NSString *testFlightToken = [self testFlightToken];