Reputation: 7484
I created a Core Data Entity called "MyObject". I then renamed the entity "ThatObject". But every time I create a NSManagedObject subclass, it still creates the .h/.m file as MyObject.
I take the "MyObject" files and just rename them to "ThatObject" and everything works, but its annoying to have to do that everytime i alter the entity attributes.
Any idea how to fix this?
Upvotes: 16
Views: 6339
Reputation: 1289
When you are renaming the entity make sure you rename both Name
and Class
in the Data Model Inspector. In my project, if both are renamed the new auto-generated NSManagedObject subclasses are created with the new names.
Upvotes: 36
Reputation: 375
For future readers: Pay attention to the model version though, if your app is already published, updating the app may break the database schema on your users devices which results in a crash on launch. Core Data can automatically find a migration for this easy case, you can find more information on lightweight migrations here. You basically have to set a renaming ID so CD knows what got renamed to what even if skipping versions in between.
Upvotes: 13