From 725da285da46caaf82640e7a096c313ad981067a Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sun, 27 Jan 2013 16:27:49 -0500 Subject: [PATCH] Minor code improvement. [FIXED] Some minor code fixes thanks to inspections. [FIXED] Some iOS6 deprecation issues. [IMPROVED] Cleanup with regards to store migration. --- .idea/inspectionProfiles/Project_Default.xml | 2 ++ External/Pearl | 2 +- MasterPassword-iOS.xcodeproj/project.pbxproj | 6 ++--- MasterPassword/MPAlgorithm.m | 1 - MasterPassword/MPAppDelegate_Store.m | 5 ++-- MasterPassword/MPConfig.m | 1 - MasterPassword/MPElementEntity.m | 1 - MasterPassword/MPKey.m | 1 - MasterPassword/MPUserEntity.m | 1 - MasterPassword/iOS/MPAppDelegate.m | 1 - MasterPassword/iOS/MPAppViewController.m | 1 - MasterPassword/iOS/MPAppsViewController.m | 1 - MasterPassword/iOS/MPGuideViewController.m | 3 --- MasterPassword/iOS/MPMainViewController.m | 1 - .../iOS/MPPreferencesViewController.m | 8 ------ MasterPassword/iOS/MPSearchDelegate.m | 9 +------ MasterPassword/iOS/MPTypeViewController.m | 17 +++++------- MasterPassword/iOS/MPUnlockViewController.m | 26 +------------------ 18 files changed, 18 insertions(+), 69 deletions(-) diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index e6ee5826..93c53611 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -5,7 +5,9 @@ + + \ No newline at end of file diff --git a/External/Pearl b/External/Pearl index 7cbc205d..b0271de7 160000 --- a/External/Pearl +++ b/External/Pearl @@ -1 +1 @@ -Subproject commit 7cbc205dd8353c4b82ee6e8229df500cdaee0b94 +Subproject commit b0271de7eb8fc9b6bb3e83fa8872b440171191d9 diff --git a/MasterPassword-iOS.xcodeproj/project.pbxproj b/MasterPassword-iOS.xcodeproj/project.pbxproj index 4693da47..8a16a04e 100644 --- a/MasterPassword-iOS.xcodeproj/project.pbxproj +++ b/MasterPassword-iOS.xcodeproj/project.pbxproj @@ -5208,7 +5208,7 @@ GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "${TARGET_NAME}"; @@ -5271,7 +5271,7 @@ GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "${TARGET_NAME}"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; @@ -5427,7 +5427,7 @@ GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_VALUE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "${TARGET_NAME}"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; diff --git a/MasterPassword/MPAlgorithm.m b/MasterPassword/MPAlgorithm.m index 1e4068b7..31fc66bc 100644 --- a/MasterPassword/MPAlgorithm.m +++ b/MasterPassword/MPAlgorithm.m @@ -16,7 +16,6 @@ // #import "MPAlgorithm.h" -#import "MPEntities.h" id MPAlgorithmForVersion(NSUInteger version) { diff --git a/MasterPassword/MPAppDelegate_Store.m b/MasterPassword/MPAppDelegate_Store.m index 2aad15dd..20db1884 100644 --- a/MasterPassword/MPAppDelegate_Store.m +++ b/MasterPassword/MPAppDelegate_Store.m @@ -42,13 +42,12 @@ static char managedObjectContextKey; - (void)migrateStoreForManager:(UbiquityStoreManager *)storeManager { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"iCloudEnabledKey"]; NSNumber *cloudEnabled = [[NSUserDefaults standardUserDefaults] objectForKey:@"iCloudEnabledKey"]; if (!cloudEnabled) + // No old data to migrate. return; if ([cloudEnabled boolValue]) { - NSURL *newCloudContentURL = [storeManager URLForCloudContent]; NSURL *newCloudStoreURL = [storeManager URLForCloudStore]; if ([[NSFileManager defaultManager] fileExistsAtPath:newCloudStoreURL.path isDirectory:NO]) // New store already exists, migration has already been done. @@ -56,6 +55,7 @@ static char managedObjectContextKey; NSString *uuid = [[NSUserDefaults standardUserDefaults] stringForKey:@"LocalUUIDKey"]; NSURL *cloudContainerURL = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:@"HL3Q45LX9N.com.lyndir.lhunath.MasterPassword.shared"]; + NSURL *newCloudContentURL = [storeManager URLForCloudContent]; //NSURL *oldCloudContentURL = [[cloudContainerURL URLByAppendingPathComponent:@"Data" isDirectory:YES] // URLByAppendingPathComponent:uuid isDirectory:YES]; NSURL *oldCloudStoreDirectoryURL = [cloudContainerURL URLByAppendingPathComponent:@"Database.nosync" isDirectory:YES]; @@ -136,6 +136,7 @@ static char managedObjectContextKey; } } } + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"LocalUUIDKey"]; [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"iCloudEnabledKey"]; } diff --git a/MasterPassword/MPConfig.m b/MasterPassword/MPConfig.m index b805a979..71d553c0 100644 --- a/MasterPassword/MPConfig.m +++ b/MasterPassword/MPConfig.m @@ -6,7 +6,6 @@ // Copyright (c) 2012 Lyndir. All rights reserved. // -#import "MPConfig.h" #import "MPAppDelegate.h" @implementation MPConfig diff --git a/MasterPassword/MPElementEntity.m b/MasterPassword/MPElementEntity.m index f0abff20..e91a237c 100644 --- a/MasterPassword/MPElementEntity.m +++ b/MasterPassword/MPElementEntity.m @@ -7,7 +7,6 @@ // #import "MPElementEntity.h" -#import "MPUserEntity.h" @implementation MPElementEntity diff --git a/MasterPassword/MPKey.m b/MasterPassword/MPKey.m index 690a7968..2fda0990 100644 --- a/MasterPassword/MPKey.m +++ b/MasterPassword/MPKey.m @@ -15,7 +15,6 @@ // Copyright 2012 lhunath (Maarten Billemont). All rights reserved. // -#import "MPKey.h" #import "MPAlgorithm.h" diff --git a/MasterPassword/MPUserEntity.m b/MasterPassword/MPUserEntity.m index 3612d715..60d190d9 100644 --- a/MasterPassword/MPUserEntity.m +++ b/MasterPassword/MPUserEntity.m @@ -7,7 +7,6 @@ // #import "MPUserEntity.h" -#import "MPElementEntity.h" @implementation MPUserEntity diff --git a/MasterPassword/iOS/MPAppDelegate.m b/MasterPassword/iOS/MPAppDelegate.m index c735e418..31f4b8d3 100644 --- a/MasterPassword/iOS/MPAppDelegate.m +++ b/MasterPassword/iOS/MPAppDelegate.m @@ -16,7 +16,6 @@ #import "MPAppDelegate_Store.h" #import "IASKSettingsReader.h" -#import "LocalyticsSession.h" @interface MPAppDelegate () diff --git a/MasterPassword/iOS/MPAppViewController.m b/MasterPassword/iOS/MPAppViewController.m index c072d4de..f0c410a5 100644 --- a/MasterPassword/iOS/MPAppViewController.m +++ b/MasterPassword/iOS/MPAppViewController.m @@ -16,7 +16,6 @@ // #import "MPAppViewController.h" -#import "LocalyticsSession.h" @implementation MPAppViewController { diff --git a/MasterPassword/iOS/MPAppsViewController.m b/MasterPassword/iOS/MPAppsViewController.m index 46da06be..3eed7543 100644 --- a/MasterPassword/iOS/MPAppsViewController.m +++ b/MasterPassword/iOS/MPAppsViewController.m @@ -16,7 +16,6 @@ // #import "MPAppsViewController.h" -#import "LocalyticsSession.h" @interface MPAppsViewController () diff --git a/MasterPassword/iOS/MPGuideViewController.m b/MasterPassword/iOS/MPGuideViewController.m index 5e348b83..2140395e 100644 --- a/MasterPassword/iOS/MPGuideViewController.m +++ b/MasterPassword/iOS/MPGuideViewController.m @@ -7,12 +7,9 @@ // #import "MPGuideViewController.h" -#import "LocalyticsSession.h" @implementation MPGuideViewController -@synthesize scrollView; -@synthesize pageControl; - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { diff --git a/MasterPassword/iOS/MPMainViewController.m b/MasterPassword/iOS/MPMainViewController.m index 603c5007..804e9b2b 100644 --- a/MasterPassword/iOS/MPMainViewController.m +++ b/MasterPassword/iOS/MPMainViewController.m @@ -10,7 +10,6 @@ #import "MPAppDelegate.h" #import "MPAppDelegate_Key.h" #import "MPAppDelegate_Store.h" -#import "LocalyticsSession.h" @implementation MPMainViewController diff --git a/MasterPassword/iOS/MPPreferencesViewController.m b/MasterPassword/iOS/MPPreferencesViewController.m index 1954728e..f3e815e4 100644 --- a/MasterPassword/iOS/MPPreferencesViewController.m +++ b/MasterPassword/iOS/MPPreferencesViewController.m @@ -11,20 +11,12 @@ #import "MPAppDelegate.h" #import "MPAppDelegate_Key.h" #import "MPAppDelegate_Store.h" -#import "LocalyticsSession.h" @interface MPPreferencesViewController () @end @implementation MPPreferencesViewController -@synthesize avatarsView; -@synthesize avatarTemplate; -@synthesize savePasswordSwitch; -@synthesize exportCell; -@synthesize changeMPCell; -@synthesize defaultTypeLabel; - - (void)viewDidLoad { diff --git a/MasterPassword/iOS/MPSearchDelegate.m b/MasterPassword/iOS/MPSearchDelegate.m index eefa1930..71f76ac4 100644 --- a/MasterPassword/iOS/MPSearchDelegate.m +++ b/MasterPassword/iOS/MPSearchDelegate.m @@ -8,7 +8,6 @@ #import "MPSearchDelegate.h" #import "MPAppDelegate.h" -#import "LocalyticsSession.h" #import "MPAppDelegate_Store.h" @interface MPSearchDelegate (Private) @@ -21,12 +20,6 @@ NSFetchedResultsController *_fetchedResultsController; } -@synthesize tipView; -@synthesize query; -@synthesize dateFormatter; -@synthesize delegate; -@synthesize searchDisplayController; -@synthesize searchTipContainer; - (id)init { @@ -38,7 +31,7 @@ self.query = @""; self.tipView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 170)]; - self.tipView.textAlignment = UITextAlignmentCenter; + self.tipView.textAlignment = NSTextAlignmentCenter; self.tipView.backgroundColor = [UIColor clearColor]; self.tipView.textColor = [UIColor lightTextColor]; self.tipView.shadowColor = [UIColor blackColor]; diff --git a/MasterPassword/iOS/MPTypeViewController.m b/MasterPassword/iOS/MPTypeViewController.m index 6a02a91d..d230aab2 100644 --- a/MasterPassword/iOS/MPTypeViewController.m +++ b/MasterPassword/iOS/MPTypeViewController.m @@ -7,7 +7,6 @@ // #import "MPTypeViewController.h" -#import "LocalyticsSession.h" @interface MPTypeViewController () @@ -17,8 +16,6 @@ @end @implementation MPTypeViewController -@synthesize delegate; -@synthesize recommendedTipContainer; #pragma mark - View lifecycle @@ -72,8 +69,8 @@ UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; - if ([delegate respondsToSelector:@selector(selectedType)]) - cell.selected = ([delegate selectedType] == [self typeAtIndexPath:indexPath]); + if ([self.delegate respondsToSelector:@selector(selectedType)]) + cell.selected = ([self.delegate selectedType] == [self typeAtIndexPath:indexPath]); return cell; } @@ -87,7 +84,7 @@ // Selected a non-type row. return; - [delegate didSelectType:type]; + [self.delegate didSelectType:type]; [self.navigationController popViewControllerAnimated:YES]; } @@ -98,7 +95,7 @@ // Generated switch (indexPath.row) { case 0: - return NSNotFound; + return (MPElementType)NSNotFound; case 1: return MPElementTypeGeneratedMaximum; case 2: @@ -112,7 +109,7 @@ case 6: return MPElementTypeGeneratedPIN; case 7: - return NSNotFound; + return (MPElementType)NSNotFound; default: { Throw(@"Unsupported row: %d, when selecting generated element type.", indexPath.row); @@ -124,13 +121,13 @@ // Stored switch (indexPath.row) { case 0: - return NSNotFound; + return (MPElementType)NSNotFound; case 1: return MPElementTypeStoredPersonal; case 2: return MPElementTypeStoredDevicePrivate; case 3: - return NSNotFound; + return (MPElementType)NSNotFound; default: { Throw(@"Unsupported row: %d, when selecting stored element type.", indexPath.row); diff --git a/MasterPassword/iOS/MPUnlockViewController.m b/MasterPassword/iOS/MPUnlockViewController.m index 00b586a5..df869123 100644 --- a/MasterPassword/iOS/MPUnlockViewController.m +++ b/MasterPassword/iOS/MPUnlockViewController.m @@ -19,7 +19,6 @@ #import "MPAppDelegate.h" #import "MPAppDelegate_Key.h" #import "MPAppDelegate_Store.h" -#import "LocalyticsSession.h" @interface MPUnlockViewController () @@ -29,32 +28,9 @@ @property (nonatomic, strong) NSArray *wordList; @property (nonatomic, strong) NSOperationQueue *fbOperationQueue; - @end @implementation MPUnlockViewController -@synthesize selectedUser; -@synthesize avatarToUser; -@synthesize spinner; -@synthesize passwordFieldLabel; -@synthesize passwordField; -@synthesize passwordView; -@synthesize avatarsView; -@synthesize nameLabel, oldNameLabel; -@synthesize avatarTemplate; -@synthesize createPasswordTipView; -@synthesize tip; -@synthesize passwordTipView; -@synthesize passwordTipLabel; -@synthesize wordWall; -@synthesize targetedUserActionGesture; -@synthesize loadingUsersIndicator; -@synthesize uiContainer; -@synthesize avatarShadowColor = _avatarShadowColor; -@synthesize wordWallAnimating = _wordWallAnimating; -@synthesize wordList = _wordList; -@synthesize fbOperationQueue = _fbOperationQueue; - - (void)initializeAvatarAlert:(UIAlertView *)alert forUser:(MPUserEntity *)user { @@ -351,7 +327,7 @@ } if (![alert textFieldAtIndex:0].text.length) { [PearlAlert showAlertWithTitle:@"Name Is Required" message:nil viewStyle:UIAlertViewStyleDefault initAlert:nil - tappedButtonBlock:^(UIAlertView *alert, NSInteger buttonIndex) { + tappedButtonBlock:^(UIAlertView *alert_, NSInteger buttonIndex_) { [self showNewUserNameAlertFor:newUser completion:completion]; } cancelTitle:@"Try Again" otherTitles:nil]; return;