Core data save model not working iOS

2019-08-19 06:06发布

问题:

I have created a core data model and when trying to save records I get the following console message: Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x8b3bc50 {metadata={ NSPersistenceFrameworkVersion = 479; NSStoreModelVersionHashes = { }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers = ( "" ); NSStoreType = SQLite; NSStoreUUID = "F49C0E04-9778-46EC-A9C7-9A045CD915D8"; "_NSAutoVacuumLevel" = 2; }, reason=The model used to open the store is incompatible with the one used to create the store}, { metadata = { NSPersistenceFrameworkVersion = 479; NSStoreModelVersionHashes = { }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers = ( "" ); NSStoreType = SQLite; NSStoreUUID = "F49C0E04-9778-46EC-A9C7-9A045CD915D8"; "_NSAutoVacuumLevel" = 2; }; reason = "The model used to open the store is incompatible with the one used to create the store"; }

I am not sure where to start to debug it please can someone tell me where the problem could be as I am new to core data.

回答1:

Remove your app from the simulator or device, clean the project and run it again.

Update: Do this only for development stages and be sure to understand the model versioning like Patrick Goley stated below.