Created
February 12, 2014 17:36
-
-
Save tgaul/8960487 to your computer and use it in GitHub Desktop.
Code from http://code-ninja.org/blog/2012/09/26/querying-data-core-data-vs-entity-framework/ done in a more compact, modern style.
This file contains hidden or 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
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