Class not found, NSManagedObject used by default instead

I have a problem with master data in iOS 8. Whenever I want to use the insertNewObjectForEntityForName method, I get

The class was not found; instead, the default NSManagedObject is used.

The error message. I use objective-c and I didn’t have this problem using IOS 7. There might also be some problem because there are two projects in my workspace, one of which contains the main code related to the data, and the other - user interface.

+7
ios objective-c ios8 core-data
source share
6 answers

This error means that you configured the class name for the entity type in the model editor, but the class does not exist at run time. The master data returns to create a shared NSManagedObject using an entity type.

Assuming the class file actually exists somewhere, the problem is that you are not including this file in the target application program in Xcode. Since Xcode supports several goals, projects, etc., It does not automatically include every source file in every assembly. Add the base data subclass files to the application target and this error should disappear.

+10
source share

When using Swift, an error can still occur if the source file is included in the phase assembly> Compile error sources

it is not possible to load a class with the name "..." for the object "...". class was not found, using nsmanagedobject by default instead.

To solve this problem, you can prefix a specific model class in the model inspector (here with MyApp). See also the documentation .

enter image description here

Ours we can add objc(Person) before your quick description declaration

 @objc(Person) class Person: NSManagedObject { ... } 
+26
source share

This is an updated version from the answer received from @ High6

Starting with Xcode 7, there is a Module property that you can set to Current Product Module (it appears automatically), so you do not need to use prefixes.

Xcode Master Data Editor

+14
source share

A similar answer to this question. In my case, I used Objective-C, and this got rid of this error in the console.

I found the answer here: Could not find a specific subclass of NSManagedObject

You can clear the “Module” field (it will show “No”) and mark subclasses of managed objects with @objc (class name)

enter image description here This fixed it for me.

+8
source share

If you are using Xcode 7 beta, the actual solution removes @objc(Person) . There must be an error in the template that is used to create entity classes in the beta version of Xcode 7.

+7
source share

When none of the solutions worked for me, I deleted the existing NSManagedObject and created a new one. If you need any code from the previous object, be sure to back up it and then copy it to the new NSManagedObject class. Hope this helps someone.

0
source share

All Articles