CoreData issue: -[NSManagedObject setValue:]: unrecognized selector sent to instance

后端 未结 8 702
温柔的废话
温柔的废话 2021-02-05 08:29

I just started with CoreData yesterday, and I\'m going crazy :( I created a project that uses CoreData (ticked the box -use CoreData). Created the entities, and then created the

8条回答
  •  Happy的楠姐
    2021-02-05 08:56

    I added an attirbute to a Core Data entity, and instead of re-creating the NSManagedObjectSubclass, I tried to get fancy and manually add the @property and @dynamic to the existing subclass.

    That didn't work, so I went and re-created the subclass through XCode, which is when I started getting this error ("unrecognized selector sent to instance" when setting a value for the attribute).

    So I created a new version of the Core Data Model via XCode, then cleaned, deleted derived data, and then re-created the NSManagedObject subclass. That worked.

    It was probably creating a new data model and the new subclass based on that, so I probably didn't need to clean or delete derived data...but it didn't hurt, either!

提交回复
热议问题