NSManagedObjectModel versionIdentifiers

前端 未结 1 1003
不思量自难忘°
不思量自难忘° 2021-01-15 04:25

The documentation for NSManagedObjectModel -versionIdentifiers says,

The Core Data framework does not give models a default identifier, nor does it de

相关标签:
1条回答
  • 2021-01-15 04:42

    Okay, well this approach did not end up being helpful for me. I solved my Core Data migration debugging problems with 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, I just now figured out the answer to my original questions, fwiw.

    If you go to your project window and select a .xcdatamodel file and 'get info', then most of the time you will get a 'File "Xxx.xcdatamodel" Info' window - with 'General', 'Targets', 'Build' and 'Comments' tabs. (Yes, the "most of the time" part has me confused.)

    However, if you then select your .xcdatamodel file again and 'get info', you will (probably) get a very different inspector - one called 'Data Model "Xxx" Info'. This window has two tabs: 'Appearance' and 'Versioning'. The Versioning tab lets you set the Model Version Identifier.

    Bottom line: Setting the Model Version Identifier in Xcode is akin to making your way to Platform 9 3/4 - but unlike 9 3/4 once you get there, it's not really clear why you'd want to be there.

    0 讨论(0)
提交回复
热议问题