From de36cf8645ed5b45ae21694e013b5cec86575877 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Fri, 5 Apr 2013 00:31:05 -0400 Subject: [PATCH] Fixes for new properties in MPAppDelegate_Store [FIXED] Properties in categories aren't synthesized. Using fancy new PearlAssociateObjectProperty from Pearl now to make a fake property. [FIXED] Show overlay on UI thread. [FIXED] ONLY_ACTIVE_ARCH = NO because weird codesign errors happen on second build with it set to YES. modified: External/Pearl --- .idea/inspectionProfiles/Project_Default.xml | 1 + External/Pearl | 2 +- External/UbiquityStoreManager | 2 +- MasterPassword/ObjC/MPAppDelegate_Store.m | 35 +++++++++---------- .../project.pbxproj | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 93c53611..04d3c3e1 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -6,6 +6,7 @@ + diff --git a/External/Pearl b/External/Pearl index 5b51c336..ee6fff8d 160000 --- a/External/Pearl +++ b/External/Pearl @@ -1 +1 @@ -Subproject commit 5b51c3360c5e173390678899f99ab89c903465de +Subproject commit ee6fff8dd4b5374c6b21c68392b5db1bf2819333 diff --git a/External/UbiquityStoreManager b/External/UbiquityStoreManager index 22dabd3a..c392d8df 160000 --- a/External/UbiquityStoreManager +++ b/External/UbiquityStoreManager @@ -1 +1 @@ -Subproject commit 22dabd3ad6f3f04bc747aebffd46a57c7f28aabd +Subproject commit c392d8df05e29a73250430cd48f5595a559f19f9 diff --git a/MasterPassword/ObjC/MPAppDelegate_Store.m b/MasterPassword/ObjC/MPAppDelegate_Store.m index e9aa6719..8a3919ff 100644 --- a/MasterPassword/ObjC/MPAppDelegate_Store.m +++ b/MasterPassword/ObjC/MPAppDelegate_Store.m @@ -9,17 +9,13 @@ #import #import "MPAppDelegate_Store.h" -@interface MPAppDelegate_Shared () - -@property(nonatomic, strong) PearlAlert *handleCloudContentAlert; -@property(nonatomic, strong) PearlAlert *fixCloudContentAlert; -@property(nonatomic, strong) PearlOverlay *storeLoading; - -@end - @implementation MPAppDelegate_Shared (Store) +PearlAssociatedObjectProperty(PearlAlert*, HandleCloudContentAlert, handleCloudContentAlert); +PearlAssociatedObjectProperty(PearlAlert*, FixCloudContentAlert, fixCloudContentAlert); +PearlAssociatedObjectProperty(PearlOverlay*, StoreLoading, storeLoading); +PearlAssociatedObjectProperty(NSManagedObjectContext*, PrivateManagedObjectContext, privateManagedObjectContext); +PearlAssociatedObjectProperty(NSManagedObjectContext*, MainManagedObjectContext, mainManagedObjectContext); -static char privateManagedObjectContextKey, mainManagedObjectContextKey; #pragma mark - Core Data setup @@ -68,13 +64,13 @@ static char privateManagedObjectContextKey, mainManagedObjectContextKey; - (NSManagedObjectContext *)mainManagedObjectContextIfReady { [self storeManager]; - return objc_getAssociatedObject( self, &mainManagedObjectContextKey ); + return self.mainManagedObjectContext; } - (NSManagedObjectContext *)privateManagedObjectContextIfReady { [self storeManager]; - return objc_getAssociatedObject( self, &privateManagedObjectContextKey ); + return self.privateManagedObjectContext; } - (void)migrateStoreForManager:(UbiquityStoreManager *)storeManager { @@ -245,7 +241,7 @@ static char privateManagedObjectContextKey, mainManagedObjectContextKey; - (void)saveContexts { - NSManagedObjectContext *mainManagedObjectContext = objc_getAssociatedObject(self, &mainManagedObjectContextKey); + NSManagedObjectContext *mainManagedObjectContext = self.mainManagedObjectContext; [mainManagedObjectContext performBlockAndWait:^{ NSError *error = nil; if (![mainManagedObjectContext save:&error]) @@ -274,11 +270,14 @@ static char privateManagedObjectContextKey, mainManagedObjectContextKey; - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager willLoadStoreIsCloud:(BOOL)isCloudStore { - if (![self.storeLoading isVisible]) - self.storeLoading = [PearlOverlay showOverlayWithTitle:@"Loading..."]; + dispatch_async(dispatch_get_main_queue(), ^{ + if (![self.storeLoading isVisible]) + self.storeLoading = [PearlOverlay showOverlayWithTitle:@"Loading..."]; + }); - objc_setAssociatedObject( self, &privateManagedObjectContextKey, nil, OBJC_ASSOCIATION_RETAIN ); - objc_setAssociatedObject( self, &mainManagedObjectContextKey, nil, OBJC_ASSOCIATION_RETAIN ); + // FIXME + //self.privateManagedObjectContext = nil; + //self.mainManagedObjectContext = nil; } - (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didLoadStoreForCoordinator:(NSPersistentStoreCoordinator *)coordinator @@ -305,8 +304,8 @@ static char privateManagedObjectContextKey, mainManagedObjectContextKey; NSManagedObjectContext *mainManagedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; mainManagedObjectContext.parentContext = privateManagedObjectContext; - objc_setAssociatedObject( self, &privateManagedObjectContextKey, privateManagedObjectContext, OBJC_ASSOCIATION_RETAIN ); - objc_setAssociatedObject( self, &mainManagedObjectContextKey, mainManagedObjectContext, OBJC_ASSOCIATION_RETAIN ); + self.privateManagedObjectContext = privateManagedObjectContext; + self.mainManagedObjectContext = mainManagedObjectContext; [self.handleCloudContentAlert cancelAlert]; [self.fixCloudContentAlert cancelAlert]; diff --git a/MasterPassword/ObjC/iOS/MasterPassword-iOS.xcodeproj/project.pbxproj b/MasterPassword/ObjC/iOS/MasterPassword-iOS.xcodeproj/project.pbxproj index fb750196..2b7ce483 100644 --- a/MasterPassword/ObjC/iOS/MasterPassword-iOS.xcodeproj/project.pbxproj +++ b/MasterPassword/ObjC/iOS/MasterPassword-iOS.xcodeproj/project.pbxproj @@ -5540,7 +5540,7 @@ "$(inherit)", "\"$(SRCROOT)/../../../External\"/**", ); - ONLY_ACTIVE_ARCH = YES; + ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-ObjC"; PRODUCT_NAME = "${TARGET_NAME}"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "";