ios - add timestamp attribute to ingredients of iphonecoredatarecipes sample code -
I'm really sorry for such a simple question, but I tried several ways and could not find the solution .
I just want to add a timestamp attribute to the content component. Whenever I change the recipes Xcdatamodel I get:
Error NSError Domain: @ "NSCocoaErrorDomain" - Code: 134100 0x000000010c162890
I already tried the model version and :
Option: @ {NSMigratePersistentStoresAutomaticallyOption: @ YES, NSInferMappingModelAutomaticallyOption: @YES}
Code is provided by Apple as!
Select your
.xcdatamodeld file in 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 2 versions for simplicity, you need to add a feature to store time. In version 2 of the file .xcdatamodeld (and I note here - be careful to select new file and not old files) Add a attribute, type it "timestamp", "date" , And Save.
Now when you run the sample project, the migration option included in your "core data stack" will migrate the stored information from the old
.xcdatamodeld file in that file's version 2 .
See also ...
UPDATE
I loaded the iPhoneCoreDataRecipes sample code, and then followed these steps. ..
- A new version of the data model was added (as described above),
- The data model in the new version is very careful to ensure that This is the new model I am modifying, the unit adds the "timestamp" attribute to the "content",
Ingredient.m file,
@ dynamic timer Tamp ,
- was added to the
Ingredient.h file, added
@property (nonatomic, retain)
RecipesAppDelegate.m In the file, the following lines of code have been added ...
NSMutableDictionary * option = [NSMutableDictionary dictionary]; [Option set value: [nsnumber number whitabulls: yes] for: nsmigatepressantenttersautomaticallipation]; [Option set value: [nsnumber number whitabulls: yes] for: mapping modeling at nsiImAtomaticallyoption];
This line of code has been changed to include my above option,
if (! [PersistentStoreCoordinator addPersistentStoreWithType: NSSQLiteStoreType Configuration: Zero URL: storeUrl Options: Option Error: & amp; Error]]
and execute a build & Run.
I got crashed with a different message ...
Can not merge model with two different entities called 'component'
which triggered a memory for which I needed to change this line of code,
managed objectModel = [[MSMed object model merged modulefund bundle: zero] Retained;
These two lines of code ...
NSURL * modelURL = [[NSBundle main bundle] URLForResource: classPersistentStore withExtension: @ "momd"]; Managed objectModel = [[nsmanned objectmodel alooc] initWithContentsOfURL: self.modelURL];
Comments
Post a Comment