I'm really sorry for such a simple question but I tried several ways and cannot find a solution.
I just want to add a timestamp attribute in the ingredients entity. Whenever I change the recipes.xcdatamodel I get this:
error NSError domain: @"NSCocoaErrorDomain" - code: 134100 0x000000010c162890
I already tried model versioning and:
options:@{NSMigratePersistentStoresAutomaticallyOption:@YES,
NSInferMappingModelAutomaticallyOption:@YES}
The code is original as provided by Apple!
Select your
.xcdatamodeldfile in the Project Navigator.Under the menu option "Editor", select "Add Model Version".
A new copy of your data model file will be created.
In this new copy, let's call it version 2 for simplicity, you need to add an attribute to store the time.
In version 2 of the
.xcdatamodeldfile (and I note here - be careful to select the new file and not the old file) add an attribute, call it "timeStamp", set the Type to "Date", and save.Now when you run the sample project, the migration options you have included in your "Core Data Stack" will migrate the stored information from the old
.xcdatamodeldfile to version 2 of that file.Also refer to... Core Data; Cocoa error 134100
UPDATE
I loaded iPhoneCoreDataRecipes sample code, and then followed these steps...
Ingredient.mfile, added@dynamic timeStamp,Ingredient.hfile, added@property (nonatomic, retain) NSDate *timeStamp;,to the
RecipesAppDelegate.mfile, added the following lines of code...changed this line of code to include my above noted options,
and executed a Build & Run.
Mine crashed with a different message...
Which triggered a memory that I was required to change this line of code,
to these two lines of code...
This loads without error for me.
Please follow these steps - should also work for you.