Class not found, using default NSManagedObject instead

前端 未结 6 768
既然无缘
既然无缘 2021-01-04 04:59

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

Class not found,

6条回答
  •  耶瑟儿~
    2021-01-04 05:45

    When using Swift the error could still appear also if the source file is included in the Build Phases > Compile Sources the error

    unable to load class named '...' for entity '...'. class not found, using default nsmanagedobject instead.

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

    enter image description here

    Our you can add objc(Person) before your swift class declaration

    @objc(Person)
    class Person: NSManagedObject {
       ...
    }
    

提交回复
热议问题