Skip to content

Instantly share code, notes, and snippets.

@nst
Created April 24, 2010 20:40
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 nst/377929 to your computer and use it in GitHub Desktop.
Save nst/377929 to your computer and use it in GitHub Desktop.
Objective-C category to ease NSManagedObject usage with a single context (.h)
#import <CoreData/CoreData.h>
@interface NSManagedObject (NST)
+ (NSManagedObjectContext *)moc;
+ (NSManagedObjectModel *)mom;
+ (NSEntityDescription *)entity;
+ (NSFetchRequest *)allFetchRequest;
+ (NSArray *)allObjects;
+ (NSUInteger)allObjectsCount;
+ (id)create;
- (NSManagedObjectContext *)moc;
- (BOOL)save;
- (void)deleteObject;
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment