Skip to content

Instantly share code, notes, and snippets.

@kyleclegg
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyleclegg/ae32ea1fc5b19359bea0 to your computer and use it in GitHub Desktop.
Save kyleclegg/ae32ea1fc5b19359bea0 to your computer and use it in GitHub Desktop.
CoreData Simple Fetch
// Substitute [ACHCoreDataHelper sharedHelper].defaultContext for the managedObjectContext
NSEntityDescription *entity = [NSEntityDescription entityForName:@"StickerPack" inManagedObjectContext:[ACHCoreDataHelper sharedHelper].defaultContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entity];
NSError *error;
NSArray *items = [[ACHCoreDataHelper sharedHelper].defaultContext executeFetchRequest:fetchRequest error:&error];
NSLog(@"items: %@", items);
StickerPack *pack = items[0];
NSLog(@"pack: %@", pack);
NSLog(@"pack stickers: %@", pack.stickers);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment