Skip to content

Instantly share code, notes, and snippets.

@spotlessicode
Last active January 3, 2017 22:10
Show Gist options
  • Save spotlessicode/e39988ce983e0a2187cd4112ef7a22c7 to your computer and use it in GitHub Desktop.
Save spotlessicode/e39988ce983e0a2187cd4112ef7a22c7 to your computer and use it in GitHub Desktop.
#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