magicalpanda/MagicalRecord — pull request #80 by ellneal (2011-10-31 00:09:49+00:00)
Title: Add support for NSManagedObject subclass names that are not the same as the CoreData entity name

Magical record uses ```NSStringFromClass([self class])``` to get the entity name for inserting/updating/deleting, but CoreData allows you to define a name for the ```NSManagedObject``` subclass that is not the same as the CoreData entity name.

For example, in my typical workflow I would have an entity named ```SomeEntity```, but I would name the ```NSManagedObject``` subclass ```FSManagedSomeEntity```. Don't ask me why I do this, I'm just very picky.

So anyway, these commits define a class method in the ```NSManagedObject+MagicalRecord``` category ```[NSManagedObject entityName]``` who's implementation calls ```NSStringFromClass([self class])``` and is called from all the places where ```NSStringFromClass([self class])``` was previously being used. This allows the subclasses of ```NSManagedObject``` to override this method and return the correct entity name. To continue my previous example, my ```FSManagedSomeEntity``` class would override ```[NSManagedObject entityName]``` like so:

````obj-c

@interface FSManagedSomeEntity : NSManagedObject
@end

@implementation FSManagedSomeEntity

+ (NSString *)entityName {

return @"SomeEntity";
}

@end
````