0

Is there a method to get a unique hash for a Core Data Managed Object Model, so that I can see if the core data store is up-to-date with a specific model? I am building a core data sync system, and I want to make sure that the core data stores which are being synced are using the same version of the managed object model.

Jason
  • 14,517
  • 25
  • 92
  • 153

1 Answers1

1

The model itself does not have a hash value, but

[managedObjectModel entities]

returns the array of entity descriptions, and each entity description has a versionHash property. You could compare these with the version hashes in the metaData dictionary of the persistent store.

But to check the compatibility of a store with a model you can also use

isConfiguration:compatibleWithStoreMetadata:

as described in "Is Migration Necessary" in the "Core Data Model Versioning and Data Migration Programming Guide".

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382