Core Data: Could not cast value of type 'MyType_MyType_2' to MyType

前端 未结 4 1857
温柔的废话
温柔的废话 2020-12-29 21:10

I have an Objective-C model class MyType. This class is used in Swift code:

NSEntityDescription.insertNewObjectForEntit         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 21:34

    I had mistakenly set a "parent entity" in one of my entities in the data model inspector in the entity section. I mistakenly thought that referred to the destination of a one-to-many relationship.

    Setting it back to "no parent entity" fixed the problem, although I did have to delete and reinstall the app in the simulator to deal with the messed up core data database.

提交回复
热议问题