My app is still in development so I am not trying to do anything fancy like migrating data from one version of my data store to another. Instead I am trying to refactor my design and part of that is moving an attribute “Foo” that belonged to entity “Entity1” over to entity “Entity2”. Using the XCode data model editor, I deleted the “Foo” attribute from “Entity1”. Then I selected “Entity2” and added a new attribute with the same name, type, and other settings that “Foo” had in “Entity1”. Thus, I moved “Foo” from “Entity1” to “Entity2”. I then recreated the managed object classes for both “Entity1” and “Entity2” and confirmed that they reflected the change (“Foo” now being a dynamic property of “Entity2” and missing from “Entity1”).
Next, I went to the /Users/mike/Library/Application Support/iPhone Simulator/4.2/Applications directory and nuked the folder that contained my app to make sure that it no longer had a .sqlite file.
Next, I went to the iOS Simulator menu and chose to Reset Content and Settings.
Next, I did a Clean in Xcode.
Finally, I built and ran my app. But what I got was an InvalidArgumentException stating that “Foo” did not exists in “Entity1” id = 4!
I thought I nuked my data store? Why does my app think that there is an object of “Entity1” with an id of 4 that has the old schema?
What is the proper way to do a refactor like this in Xcode?
Please help!
Figured it out. My problem was not how I changed the data model but rather that I had a predicate that was still referring to the “Foo” attribute in “Entity1”.