Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3.0 & Swift: NSFetchRequest could not locate an NSEntityDescription for entity name <<MODULENAME>>.MyEntity #1063

Closed
csotiriou opened this issue Aug 18, 2015 · 0 comments

Comments

@csotiriou
Copy link
Contributor

Hello,

I noticed that in branch 3.0, a fix that was done in 2.x concerning name prefixes of entities in Swift has been removed from NSManagedObject, in -MR_entityName

OLD (v 2.0) - Working:

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

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

    if ([entityName length] == 0)
    {
        // Remove module prefix from Swift subclasses
        entityName = [NSStringFromClass(self) componentsSeparatedByString:@"."].lastObject;
    }

    return entityName;
}

NEW (v 3.0) - Not working

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

    if ([self respondsToSelector:@selector(entityName)])
    {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wselector"
        entityName = [self performSelector:@selector(entityName)];
#pragma clang diagnostic pop
    }

    if ([entityName length] == 0)
    {
        entityName = NSStringFromClass(self);
    }

    return entityName;
}

The reason it doesn't work for me in Swift, is because it doesn' handle the entity names containing the Module name in the class. Is there any reason why this fix didn't make it from version 2 to version 3? Even if Xcode 7 has made changes to Core Data entity names, having your core data entities in a shared embedded framework (which is my case) still prefixes the names of the classes, so in my opinion, the fix should be preserved from version 2 to version 3.

Is it valid to transfer it, or there is a reason why this was omitted in 3.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant