Last active
January 3, 2017 22:10
-
-
Save spotlessicode/e39988ce983e0a2187cd4112ef7a22c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - SYNC | |
- (QSCloudKitSynchronizer *)synchronizer | |
{ | |
if ([self iCloudEnabledByUser] && [self iCloudAccountIsSignedIn]) { | |
NSLog(@"** iCloud available SYNCHRONIZER! **"); | |
if (!_synchronizer) { | |
_synchronizer = [QSCloudKitSynchronizer cloudKitSynchronizerWithContainerName:@"iCloud.com.SyncKitTest" managedObjectContext:self.managedObjectContext changeManagerDelegate:self]; | |
} | |
}else{ | |
NSLog(@"** iCloud not available **"); | |
} | |
return _synchronizer; | |
} | |
- (void)sync{ | |
NSLog(@"Synchronize View"); | |
[self.synchronizer synchronizeWithCompletion:^(NSError *error) { | |
NSLog(@"Synchronize Complete"); | |
if (error) { | |
NSLog(@"Synchronize ERROR"); | |
//[[NSNotificationCenter defaultCenter]postNotificationName:@"synced" object:self]; | |
}else{ | |
NSLog(@"Synchronize NO ERROR"); | |
NSFetchRequest *request = | |
[[self.managedObjectModel fetchRequestTemplateForName:@"getAllCompanies"]copy]; | |
NSArray *companiesArray = [self.managedObjectContext executeFetchRequest:request error:nil]; | |
NSLog(@"companiesArray count %lu", (unsigned long)companiesArray.count); | |
//[[NSNotificationCenter defaultCenter]postNotificationName:@"synced" object:self]; | |
} | |
}]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment