Skip to content

Instantly share code, notes, and snippets.

@tgaul
Created February 12, 2014 17:36
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 tgaul/8960487 to your computer and use it in GitHub Desktop.
Save tgaul/8960487 to your computer and use it in GitHub Desktop.
NSFetchRequest* fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Widget"];
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"type == %@", someType];
fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"createddate" ascending:YES]];
fetchRequest.fetchLimit = 5;
NSError* error;
NSArray* widgets = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment