mluisbrown / iCloudCoreDataStack

A persistence stack for using Core Data with iCloud Sync in iOS7
126 stars 11 forks source link

How to synchronize the data added by the user before connect the iCloud? #2

Closed nullproduction closed 10 years ago

nullproduction commented 11 years ago

Thanks for the good example. If you create an entry in CoreData, and then add in the settings of your account icloud.

Old records records disappear + crash:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Object's persistent store is not reachable from this NSManagedObjectContext's coordinator'

How to synchronize the data added by the user before connect the iCloud?

mluisbrown commented 11 years ago

You're getting that exception because your persistent store has changed and you're holding on to an NSManagedObject from the previous store, which is now invalid. After PersistentStack storesWillChange: is called any NSManagedObject you had previously is now invalid. That's why we save and reset the NSManagedObjectContext to prepare for the new store.

In your implementation of storesWillChange you'll need to ensure that your app doesn't hold onto any NSManagedObject objects. You need to be prepared to receive a completely new set of data.

nullproduction commented 11 years ago

Thanks for the reply.