Skip to content

Instantly share code, notes, and snippets.

@quellish
Created September 29, 2014 07:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save quellish/18060690b3cb9ddbec32 to your computer and use it in GitHub Desktop.
Save quellish/18060690b3cb9ddbec32 to your computer and use it in GitHub Desktop.
allPeopleInManagedObjectContext
- (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];
[fetchRequest setEntity:entity];
[fetchRequest setPredicate];
results = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
completion(results, error);
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment