IOS 7 - CoreData Migration - Xcode 5

I have a very curious problem with performing a CoreData migration.

Basically, I have 2 objects where in one of them I add a property, and in the other I change the type of the property from NSString to NSArray (Transformable). So far, so good, it works well, tests have been done, and data integrity has been intact after migration.

The problem arises if I run the same code on Xcode 5 (I don’t know if this is related to iOS SDK 7.0 or Xcode 5), but the migration starts and distorts the data.

In the end, I created a simple project to demonstrate what is happening. https://dl.dropboxusercontent.com/u/1393279/CoreDataMigration.zip

Steps to play: - On Xcode 5 (iOS SDK 7.0) you can use the simulator -

1 - Open the "BeforeMigration" project and execute. See Logs and Created Data, no problem so far;

2 - Stop the project;

3 - Open the project "After migration", execute it and run.

4 - See that the migration is completed, but the data is corrupted:

2013-11-13 12: 22: 29.778 CoreDataMigration [7223: 70b] CoreData: error: exception during fetchRowForObjectID: * - [NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x43, 0x32, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0. 0x0) with userInfo (null) 2013-11-13 12: 22: 29.782 CoreDataMigration [7223: 70b] Application termination due to an uncaught exception "NSInvalidArgumentException", reason: ** - [NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x43, 0x32,0x0,0x0,0x0,0x0,0x0,0x0) '

AFAIK, CoreData.

, , , , Xcode 4.5. CoreData Diffs, .

- , , . .

+4
2

iOS 7 Core Data SQLite (WAL) , concurrency.

, -wal . - :

NSDictionary *options = @{NSSQLitePragmasOption:@{@"journal_mode":@"DELETE"}};

-wal :

- (NSPersistentStore *)migratePersistentStore:(NSPersistentStore *)store toURL:(NSURL *)URL options:(NSDictionary *)options withType:(NSString *)storeType error:(NSError **)error
+3

moagenerator :

  • MOGen ( MOGenerator), ( -);
  • ;
  • :

    • - " "; (: 1.1 2.0 ..). , , - Core Data -, ;

    • , , . , "MyDataModel.xcdatamodel", 1.1 - "MyDataModel_1.1.xcdatamodel";

    • , "MyDataModel.xcdatamodel", . , , / MOGen ( , MOGen - );

    • ;

    • , , Core Data Lightweight Migration . , , ;

    • ;

    • ;

    • .

+2

All Articles