Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomasf/tfcoredataextras
Categories to simplify Core Data usage.
https://github.com/tomasf/tfcoredataextras
Last synced: 7 days ago
JSON representation
Categories to simplify Core Data usage.
- Host: GitHub
- URL: https://github.com/tomasf/tfcoredataextras
- Owner: tomasf
- Created: 2011-08-21T10:11:55.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-12-22T18:41:46.000Z (about 12 years ago)
- Last Synced: 2023-04-12T04:03:39.247Z (almost 2 years ago)
- Language: Objective-C
- Homepage:
- Size: 105 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
BSD-licensed.
TFCoreDataExtras simplifies Core Data usage. Most things assume you've created class files from your model. It helps you:
* Set up new managed object contexts (loading the store and model for you). `+managedObjectContextFromModelNamed:storeName:type:` loads a model with the specified name from your Resources and associates it with a store from Application Support.
* Create objects. `-initWithEntity:insertIntoManagedObjectContext:` is now `-initInsertingIntoManagedObjectContext:` – the entity is looked up automatically.
* Find objects. In most cases, you no longer need to create fetch requests. Send `+objectsInManagedObjectContext:sortedBy:ascending:matchingPredicateFormat:` (or one of the related methods) to your `NSManagedObject` subclass.Example
==NSArray *people = [MYPerson objectsInManagedObjectContext:moc sortedBy:@"firstName" ascending:YES matchingPredicateFormat:@"city = %@", @"Boston"];
Without TFCoreDataExtras:
NSFetchRequest *req = [[NSFetchRequest alloc] init];
[req setEntity:[NSEntityDescription entityForName:@"Person" inManagedObjectContext:moc]];
[req setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"firstName" ascending:YES]]];
[req setPredicate:[NSPredicate predicateWithFormat:@"city = %@", @"Boston"]];
NSArray *people = [moc executeFetchRequest:req error:NULL];