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
- (void) fetchThingsWithCompletion:(void (^)(NSArray *, NSError *))completion{ | |
[context performBlock:^{ | |
result = [context executeFetch:... | |
if (completion != nil){ | |
completion(result, error); | |
} | |
}]; | |
} |
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
group = dispatch_group_create(); | |
dispatch_group_enter(group); | |
[context performBlock:^{ | |
result = [context executeFetch:... | |
dispatch_group_leave(group); | |
}]; | |
groupResult = dispatch_group_wait(group, DISPATCH_TIME_FOREVER); |
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
- (void) saveManagedObjectContext:(NSManagedObjectContext *)managedObjectContext withCompletion::(void (^)(BOOL, NSError *))completio{ | |
managedObjectContext performBlock:^{ | |
NSError *error = nil; | |
if (![managedObjectContext save:&error]){ | |
completion(NO, error); | |
} else { | |
if ([managedObjectContext parentContext] != nil){ | |
[self saveManagedObjectContext:[managedObjectContext parentContext] withCompletion:completion]; | |
} else { |
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
- (void) allPeopleInManagedObjectContext:(NSManagedObjectContext *)managedObjectContext withCompletion:(void (^)(NSArray*, NSError*))completion { | |
[managedObjectContext performBlock:^{ | |
NSError *error = nil; | |
NSArray *results = nil; | |
NSFetchRequest *fetchRequest = nil; | |
NSPredicate *predicate = nil; | |
NSEntityDescription *entity = nil; | |
fetchRequest = [[NSFetchRequest alloc] init]; | |
entity = [NSEntityDescription entityForName:@"Person" inManagedObjectContext:context]; |
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
[managedObjectContext performBlock:^{ | |
NSError *error = nil; | |
if (![managedObjectContext save:&error]){ | |
[self handleError:error]; | |
} | |
}]; |
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
[[managedObject managedObjectContext] performBlock:^{ | |
NSString *value = [managedObject someValue]; | |
[NSOperationQueue mainQueue] addOperationWithBlock:^{ | |
[[self label] setText:value]; | |
}]; | |
}]; |