Skip to content

Instantly share code, notes, and snippets.

@gonzalezreal
Created October 24, 2012 06:50
Show Gist options
  • Select an option

  • Save gonzalezreal/3944444 to your computer and use it in GitHub Desktop.

Select an option

Save gonzalezreal/3944444 to your computer and use it in GitHub Desktop.
+ (NSString *)entityName
{
return NSStringFromClass([self class]);
}
+ (NSFetchRequest *)fetchRequest
{
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:[self entityName]];
[fetchRequest setFetchBatchSize:25];
return fetchRequest;
}
+ (id)insertNewObjectInManagedObjectContext:(NSManagedObjectContext *)context
{
return [NSEntityDescription insertNewObjectForEntityForName:[self entityName]
inManagedObjectContext:context];
}
+ (id)importFromDictionary:(NSDictionary *)dictionary inManagedObjectContext:(NSManagedObjectContext *)context
{
TGRManagedObject *object = [self insertNewObjectInManagedObjectContext:context];
[object importValuesFromDictionary:dictionary];
return object;
}
- (void)importValuesFromDictionary:(NSDictionary *)dictionary
{
// Must be overridden by subclasses
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment