kylef-archive / KFData

Core Data done right for iOS 5+/OS X 10.7+
http://cocoadocs.org/docsets/KFData/
BSD 2-Clause "Simplified" License
53 stars 7 forks source link

A new way to query Core Data (KFObjectManager) #49

Closed kylef closed 11 years ago

kylef commented 11 years ago

This removes dozens of category methods on managed object which are now replaced by the new KFObjectManager. This manager is an immutable object which can be used to create fetch requests and optionally execute them.

The new approach also handles passing NSError's back instead of silently handling failures.

Examples of usage:

KFObjectManager *manager = [Person managedInManagedObjectContext:moc];

NSLog(@"We have %d people!", [manager count:nil]);

for (Person *person in manager) {
    NSLog(@"Hello %@", [person name]);
}
KFObjectManager *manager = [[Person managedInManagedObjectContext:moc] exclude:[[Person name] equal:@"Kyle"]];

NSLog(@"We have %d people (excluding Kyle)!", [manager count:nil]);