Question

I extended yesterday my "User" class, which is a subclass of NSManagedObject. I added a new property named "photoPath", the usual way:

@property (nonatomic, retain) NSString * photopath;
@dynamic photoPath;

I added a new version of my Data Model and implemented successfully the data migration. Everything worked perfectly!... since now. Today, when I access my new property, the app crashes and says :

-[User photoPath]: unrecognized selector sent to instance xxx

No code have been touched since yesterday, I only closed and re-opened Xcode.

So what could be the f*** magic which makes an app working a day and crashing the next day? I know CoreData generate some files like .momd. I've cleaned everything. Any suggestion?

It seems that coreData stays on the old object model and I don't know why.....

EDIT :

When I check the Project.sqlite file, the "photoPath" column do not even exist. Any idea?

Was it helpful?

Solution 2

OKAY

Of course, under my .xdatamodeld (Versioned Core Data Model) the good version was selected, I had triple checked that before posting.

But i still tried to select the old one, save, re-select the new one, save.

And it works...

Many, many thanks to Xcode which made me loose 2 hours

EDIT : The problem comes back each time I close and re-open my project. I always have to do the procedure described above before launching the app. It is very annoying. If someone know how a better solution, I would accept his answer.

OTHER TIPS

Two things I always do after changing a core data model or subclass. Delete the instance of the app from the device/simulator. Clean the project.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top