Skip to content

Instantly share code, notes, and snippets.

@nicktoumpelis
Last active August 29, 2015 14:05
Show Gist options
  • Save nicktoumpelis/cb59f9076cc009972b99 to your computer and use it in GitHub Desktop.
Save nicktoumpelis/cb59f9076cc009972b99 to your computer and use it in GitHub Desktop.
Core Data: Create a simple NSFetchRequest
NSManagedObjectContext *managedObjectContext = ...;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[NSEntityDescription entityForName:@"Entity" inManagedObjectContext:managedObjectContext]];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"..."];
[fetchRequest setPredicate:predicate];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"key" ascending:YES];
[fetchRequest setSortDescriptors:@[sortDescriptor]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment