开发者

How do you clean Core Data generated models and code from a project?

I'm having an extremely annoying problem with Core Data in the iPhone SDK. I would say in general Core Data for the most part appears easy to use and nice to implement.

I have a sqlite database that is being used as a read only reference to pull data elements out for an iPhone app. It would seem there are really mysterious issues relating to what seems to be migration of the database to the most recent versions of my schema.

Why can't you just clean out your stored objects and models and let a project redo all of it when you compile next? You would think if you setup a stored object model there would be a way to just reset it and recompile. I've tried what feels like a thousand 'tips' that have been the results of ho开发者_高级运维urs of google searches and documentation prowling to figure out how to do this.

My most recent error during compile time is below.

2010-04-07 18:23:51.891 PE[1962:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't merge models with two different entities named 'PElement''

All of this code has been working in the simulator and is only causing me troubles now because I made a change to the schema. I also have the database options for automatically migrating set as below.

NSMutableDictionary *optionsDictionary = [NSMutableDictionary dictionary];
[optionsDictionary setObject:[NSNumber numberWithBool:YES] 
    forKey:NSMigratePersistentStoresAutomaticallyOption];

[optionsDictionary setObject:[NSNumber numberWithBool:YES]
    forKey:NSInferMappingModelAutomaticallyOption];


Clean your project. Xcode does not delete the old compiled mom file out of the bundle when you start versioning. Cleaning the project before your next build will resolve this issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜