nofelmahmood / Seam

Seamless CloudKit Sync with CoreData
https://medium.com/@Nofel/reason-why-cloudkit-cannot-be-ignored-9c7806d76230
MIT License
671 stars 65 forks source link

Need to handle iCloud account changes #11

Open johnthuss opened 9 years ago

johnthuss commented 9 years ago

If the user switches iCloud accounts their local data will no longer match the server's data. In that case you would need initiate a complete two-way sync of all records stored both locally and on the server. In iOS 9 there is a notification you can subscribe to so you know when the account change happens, but in iOS 8 I believe the only option is to record the user's iCloud ID and poll it for changes periodically (like at startup?). Alternatively, providing a button to manually initiate a complete sync might be acceptable.

nofelmahmood commented 9 years ago

Yes you are right. But personally I think that can be left to the user of this library to handle. Like at the end of the day it's a store added to your app's NSPersistentStoreCoordinator. In case of this you can remove the store and add a new one and start fresh ?

nofelmahmood commented 9 years ago

I am actually decoupling the code. It will then be more easy to find bugs and fix them and it looks clean too. You don't need to worry about them. The usage will remain the same.

The selector name was for the demo project. It's your choice, name it whatever you like. These two notifications are posted to notify the start and end of the sync operation.

I know its taking time but I assure it will be worth the wait. I'l close this issue when it's completely upgraded to Swift 2.0. You can subscribe to it to be notified when that happens :)

nofelmahmood commented 9 years ago

Don't worry man ! The decoupling of code would not have any impact on the user side. It's all to make code look clean, readable and of course testable. You'l only have to add the store with CKSIncrementalStore type to your app's NSPersistentStoreCoordinator as usual to use it :)

nofelmahmood commented 9 years ago

Sorry I didn't because of my busy schedule :( You can check out the master branch right now btw.