Thursday 15 May 2014

ios - iPhone Core Data "Automatic Lightweight Migration" -


I'm trying to update an app that implements core data store. Adding the attribute

I said the following code for my representative class:

  - (NSPersistentStoreCoordinator *) persistentStoreCoordinator {if (! PersistentStoreCoordinator = Void) {return persistentStoreCoordinator; } NSURL * storeUrl = [NSURL fileURLWithPath: [[Self-Application Document Directory] stringBeeAppendingPathComponent: @ "Shoppee.sqlite"]]; NSError * Error = Zero; Continuous store coordinator = [[NSPSlistListCoDditorALOC] initWithManagedObjectModel: [Self-managed object model]]; NSDictionary * Options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool: Yes], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool: Yes], NSInferMappingModelAutomaticallyOption, zero]; If (Continuous Store Cordinator Extender Storey Type: NSSQLiteStoreType Configuration: Zero URL: Store URL Options: Option Error: & amp; Error]) {NSLog (@ "Error:% @", error); NSLog (@ "Unsolver Error% @,% @", Error, [Error User Information]); Abortion (); } Return Constant Store Coordinator; }  

It was from the following URL:

I get the following error while executing the code:

2009-12- 01 Shoppee [25633: 207] Error: error

domain = NSCocoaErrorDomain code = 134,130

UserInfo = 0x1624d20 "operation could not be performed: 20: 04: 22.877

Shoppee [ Complete (Coco error 134130.) "2009-12-01 20: 04: 22.879 Shoppee [25,633: 207] Unsolved error error domain = NSCocoaErrorDomain code = 134,130 UserInfo = 0x1624d20". Operation can not be completed (Coco error 134130 .) ", {URL = File: // localhost / Users / Eric / Library / Application% 20Support / iPhone% 20Simulator / User / Applications / A 8A8FB73-9AB9-4EB7-8F83-82F5B4467AF1 / Documents / MyApp.sqlite; Metadata = {NSPersistenceFrameworkVersion = 241; NSStoreModelVersionHashes = {item = & lt; 869d4b20 088e5c44 5c345006 87d245cd 67ab9bc4 14cadf45 180251e9 f741a98f>; Store = & lt; 47c250f4 895e6fd1 5033ab42 22d2d493 7819ba75 3c0acffc 2dc54515 8deeed7a>; }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers = (); NSStoreType = SQLite; NSSTUUIDID = "8 DC 65301-3 BC 5-42 BE-80B8-E44577B 8F8E1"; }; Cause = "Model can not be found for source store"; }

It seems that I need to include the original data model, but I'm not sure how to do this. any suggestion?

To summarize / complete guide:

  1. Before making any changes, create a new model version.

    In Xcode 4: Choose your .xcdatamodel -> Editor - Add Model Version

    In Xcode 3: Design -> Data Model -> Add Model Version

    You will notice that a new .xcdatamodel has been created in your .xcdatamodeld folder (which is also

  2. Do your new .xcdatamodel and make the change that you .

  3. Save

  4. Set Current / Active Setting of the newly created schema Schema for

    .xcdatamodeld with selected folder:

    In Xcode 4: Utilities Sidebar -> File Inspector -> Convergent Core Data Model -> Choose New Schema

    In Xcode 3: Design> Data Model> Set Current Version

    .xcdatamodel The green tick on the icon will go to the new schema.

  5. Save.

  6. To migrate to runtime Apply the code required for The Options parameter, null Replace with the following code

    where your NSPersistentStoreCoordinator is created (usually app Aglaiatt Class),:

      [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool: Yes], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool: Yes], NSInferMappingModelAutomaticallyOption, zero]  
  7. then run your app if there is no crash, presumably you've already migrated successfully :)

  8. when you migrate successfully, my Reshn code (step 7) can be removed. (This can be understood when the developer migrate user-dependent when published app on set.)

Important: Delete old model version / schema core version requires an older version to migrate to the new version.


No comments:

Post a Comment