diff --git a/ZP/AppDelegate.m b/ZP/AppDelegate.m index 5bbbc43..ea112cc 100644 --- a/ZP/AppDelegate.m +++ b/ZP/AppDelegate.m @@ -38,9 +38,6 @@ - (BOOL) application:(UIApplication *)application NSLog(@"url: %@", url); }]; -// [DDLog addLogger:[DDASLLogger sharedInstance]]; -// [DDLog addLogger:[DDTTYLogger sharedInstance]]; - [Fabric with:@[[Crashlytics class]]]; [AFNetworkActivityIndicatorManager sharedManager].enabled = YES; @@ -48,12 +45,11 @@ - (BOOL) application:(UIApplication *)application [LMGeocoder sharedInstance].googleAPIKey = ZPPGMSApiKey; if (IS_OS_8_OR_LATER) { - [application - registerUserNotificationSettings:[UIUserNotificationSettings - settingsForTypes:(UIUserNotificationTypeSound | - UIUserNotificationTypeAlert | - UIUserNotificationTypeBadge) - categories:nil]]; + [application registerUserNotificationSettings:[UIUserNotificationSettings + settingsForTypes:(UIUserNotificationTypeSound | + UIUserNotificationTypeAlert | + UIUserNotificationTypeBadge) + categories:nil]]; [application registerForRemoteNotifications]; } @@ -62,24 +58,12 @@ - (BOOL) application:(UIApplication *)application } - (void)applicationWillResignActive:(UIApplication *)application { - // Sent when the application is about to move from active to inactive state. This can occur for - // certain types of temporary interruptions (such as an incoming phone call or SMS message) or - // when the user quits the application and it begins the transition to the background state. - // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame - // rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { - // Use this method to release shared resources, save user data, invalidate timers, and store - // enough application state information to restore your application to its current state in case - // it is terminated later. - // If your application supports background execution, this method is called instead of - // applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { - // Called as part of the transition from the background to the inactive state; here you can undo - // many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { @@ -90,7 +74,11 @@ - (void)applicationWillTerminate:(UIApplication *)application { [self saveContext]; } -- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { +- (BOOL)application:(UIApplication *)application + openURL:(NSURL *)url + sourceApplication:(NSString *)sourceApplication + annotation:(id)annotation { + return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication @@ -112,8 +100,10 @@ - (NSManagedObjectModel *)managedObjectModel { if (_managedObjectModel != nil) { return _managedObjectModel; } + NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"ZP" withExtension:@"momd"]; _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; + return _managedObjectModel; } @@ -129,8 +119,8 @@ - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"ZP.sqlite"]; NSError *error = nil; - NSString *failureReason = - @"There was an error creating or loading the application's saved data."; + NSString *failureReason = @"There was an error creating or loading the application's saved data."; + if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL @@ -158,8 +148,7 @@ - (NSManagedObjectContext *)managedObjectContext { if (!coordinator) { return nil; } - _managedObjectContext = - [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; + _managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; [_managedObjectContext setPersistentStoreCoordinator:coordinator]; return _managedObjectContext; } @@ -170,6 +159,7 @@ - (void)saveContext { NSManagedObjectContext *managedObjectContext = self.managedObjectContext; if (managedObjectContext != nil) { NSError *error = nil; + if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); @@ -179,8 +169,7 @@ - (void)saveContext { #pragma mark - Push notifications -- (void) application:(UIApplication *)application -didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { +- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { [[ZPPUserManager sharedInstance] setAPNsToken:deviceToken]; } diff --git a/ZP/UIButton+ZPPButtonCategory.m b/ZP/UIButton+ZPPButtonCategory.m index d2a37f0..bfb2fda 100644 --- a/ZP/UIButton+ZPPButtonCategory.m +++ b/ZP/UIButton+ZPPButtonCategory.m @@ -20,6 +20,7 @@ - (void)stopIndication { [v removeFromSuperview]; } } + self.enabled = YES; } @@ -30,17 +31,14 @@ - (void)startIndicating { - (void)startIndicatingWithType:(UIActivityIndicatorViewStyle)style { [self stopIndication]; [[UIApplication sharedApplication] beginIgnoringInteractionEvents]; - UIActivityIndicatorView *v = - [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:style]; + UIActivityIndicatorView *v = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:style]; [v startAnimating]; CGSize size = v.frame.size; - v.frame = CGRectMake(8, (self.frame.size.height - size.height) / 2.0, v.frame.size.width, - v.frame.size.height); + v.frame = CGRectMake(8, (self.frame.size.height - size.height) / 2.0, v.frame.size.width, v.frame.size.height); [self addSubview:v]; - self.enabled = NO; }