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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With