Separate Local Datastore
As I understand it, the idea here is to:
- Have 1 SQL store for both local and cloud persistence
- Depending on what the user selects (cloud enabled or not), the store is opened with ubiquity enabled or not.
- When the store is modified while ubiquity is disabled, opening the store later with ubiquity enabled causes problems.
- When the store is modified while ubiquity is enabled but disabled on another device, opening the other device's store later with ubiquity enabled causes problems.
- To address these problems, sentinels are used that cause the cloud data to get reset to the store data whenever the app enables ubiquity and its store had previously been enabled for ubiquity.
Wouldn't it be possible to get rid of the whole problem by using 2 SQL stores instead of 1? Always open SQL store A when the user chooses to disable ubiquity and store B when the user enables it. That way, iCloud enabled/disabled would trigger the app to switch between different data sets, but you wouldn't need sentinels. Is this a correct assumption? Are there advantages to the sentinel approach?
Your suggestion is pretty much what Apple's sample code does.
The sentinel is less needed now, because 10.8 and iOS 6 have built in support for when a user disables or switches iCloud accounts. These can fulfill the role of the sentinel, so new code doesn't really need them.
The question of how the data should be moved around depends largely on the type of app you have, I think. If you think it makes sense for each iCloud account, and an offline option, to have different data, then you approach is fine. This would make sense for a contacts app, for example.
But I can think of other apps where the user would be perplexed if their data all of a sudden disappeared when switching accounts. They see iCloud in that case as just a syncing framework, not as an online storage solution, and they expect the data to stay the same even when they switch accounts.
Drew
On Nov 15, 2012, at 11:58 PM, Maarten Billemont [email protected] wrote:
As I understand it, the idea here is to:
Have 1 SQL store for both local and cloud persistence Depending on what the user selects (cloud enabled or not), the store is opened with ubiquity enabled or not. When the store is modified while ubiquity is disabled, opening the store later with ubiquity enabled causes problems. When the store is modified while ubiquity is enabled but disabled on another device, opening the other device's store later with ubiquity enabled causes problems. To address these problems, sentinels are used that cause the cloud data to get reset to the store data whenever the app enables ubiquity and its store had previously been enabled for ubiquity. Wouldn't it be possible to get rid of the whole problem by using 2 SQL stores instead of 1? Always open SQL store A when the user chooses to disable ubiquity and store B when the user enables it. That way, iCloud enabled/disabled would trigger the app to switch between different data sets, but you wouldn't need sentinels. Is this a correct assumption? Are there advantages to the sentinel approach?
— Reply to this email directly or view it on GitHub.