Skip to content

Commit

Permalink
Merge pull request #974 from csotiriou/develop
Browse files Browse the repository at this point in the history
Fixes for `MR_entityName` when using Swift
  • Loading branch information
tonyarnold committed Mar 2, 2015
2 parents 2da4639 + 55c8756 commit 81d6f84
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -13,15 +13,17 @@ @implementation NSManagedObject (MagicalRecord)

+ (NSString *) MR_entityName;
{
NSString *entityName;

if ([self respondsToSelector:@selector(entityName)])
NSString *entityName;
if ([self respondsToSelector:@selector(entityName)])
{
entityName = [self performSelector:@selector(entityName)];
}

if ([entityName length] == 0) {
entityName = NSStringFromClass(self);
if ([entityName length] == 0)
{
//swift prefixes classes, like ModuleName.MyClass and this causes problems with Core Data and NSSTringFromClass. We must handle that.
entityName = [NSStringFromClass(self) componentsSeparatedByString:@"."].lastObject;
}

return entityName;
Expand Down

0 comments on commit 81d6f84

Please sign in to comment.