NSManagedObjectModel versionIdentifiers

The documentation for NSManagedObjectModel -versionIdentifiers says:

The Core Data structure does not give models a default identifier and does not depend on this value at run time. For models created in Xcode, you set this value in the model inspector.

I'm not sure, but I think setting version identifiers can help me when I talk about the coding model migration policy classes. Does anyone know how to set these identifiers in Xcode? I talked unsuccessfully around.

Thanks.

+2
source share
1 answer

Well, this approach did not help me. I solved the problems with debugging Core Data migration using the following code:

NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"Spark.sqlite"]]; NSError *error = nil; NSDictionary *sourceMetadata = [NSPersistentStoreCoordinator metadataForPersistentStoreOfType:NSSQLiteStoreType URL:storeUrl error:&error]; if (!sourceMetadata) NSLog(@"sourceMetadata is nil"); else NSLog(@"sourceMetadata is %@", sourceMetadata); 

On the other hand, I just realized the answer to my original questions, fwiw.

If you go to the project window and select the .xcdatamodel file and “get information”, most of the time you will get the “Information” window Xxx.xcdatamodel “Information” - with “General”, “Goals”, 'Build' and 'Comments' . (Yes, the “most of the time” part bothers me.)

However, if you then select your .xcdatamodel file again and “get the information”, you will probably get a completely different inspector called the “Data Model” Xxx “Info”. There are two tabs in this window: Appearance and Versions. On the "Versions" tab, you can set the version identifier of the model.

Bottom line: setting the model version identifier in Xcode is akin to getting to the 9 3/4 platform, but unlike 9 3/4, when you get there, it's not entirely clear why you want to be there.

+3
source

All Articles