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

Forced to change NSManagedObject subclasses #2181

Closed
besi opened this issue Mar 7, 2015 · 3 comments
Closed

Forced to change NSManagedObject subclasses #2181

besi opened this issue Mar 7, 2015 · 3 comments

Comments

@besi
Copy link
Contributor

besi commented Mar 7, 2015

I have a project where I have introduced Swift classes.

As soon as I ran the project I ran into this assertion:

 NSAssert(objectClass, @"Cannot initialize an entity mapping for an entity with a nil managed object class: Got nil class for managed object class name '%@'. Maybe you forgot to add the class files to your target?", [entity managedObjectClassName]);

See RKEntityMapping.m:166

With the help of the SO Post Swift RestKit CoreData - RKEntityMapping nil class for class name I was able to resolve the issue.

So what I did is update my Swift file with the objc( ) annotation like so:

// Issue.swift

import Foundation
import CoreData

// TODO: This was added manually. Not nice.
@objc(Issue)

class Issue: NSManagedObject {

    @NSManaged var repository: Repository
    @NSManaged var responsible: User
    @NSManaged var version: Version

}

I am wondering if there is a better way around this issue. Because as soon as I will update the model and re-generate the classes the correction will be overwritten again.

@loicgriffie
Copy link

Either you can create a subclass for that inherit from Issue class and add the @objc() statement or use mogenerator to automate the process

@ocwang
Copy link

ocwang commented Oct 7, 2015

I ran into the same issue after auto-generating a new entity with XCode 7.0. I solved this by going to the Data Model Inspector for the respective entity and deleting the 'Module' field.

See SO post for reference: http://stackoverflow.com/questions/25076276/unable-to-find-specific-subclass-of-nsmanagedobject

@segiddins
Copy link
Member

You can also use the fully qualified class name: Module.ClassName.

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

4 participants