简体   繁体   中英

Core-Data & iCloud limit number of items per entity - Potential Sync issue

I am currently developing an app that uses core-data and hopefully uses iCloud. I have an issue thou - My app has ONE profile entity where everything fall of it.

I would like to sync this with iCloud so it also works with their other devices eg iPad. I have an issue however and described in the scenario below:

Scenario 1

User uses their iPhone for my app. Create a profile and use it for some time. They then get an iPad, use my app for the first time without network - The app will them prompt them to create a profile. (User does so without really thinking ive already done this). They then open the app the next day with network - their is now 2 objects in my profile entity effectively for the same person.

How would i go about getting around this scenario? Below is a few ideas but I'm kinda puzzled where to continue

  • Option 1 is check they have iCloud enabled - and prompt them have they used this app before?
  • Option 2 Watch the profile object and merge the two together (Risky move)
  • Option 3 Dont use iCloud - (Dont really wanna do this)

Any tips or ideas would be great.

Dan

you can just avoid inserting duplicate records in profile entity by using delete method available for core data. Before inserting data in profile entity call delete which will delete duplicate entry and insert new entry.

You really want to be able to handle #2. Beyond the scenario you outlined, there are all sorts of other ways the two devices could get out of sync.

That said, you could, at the detection of two sets of competing data, ask the user which one they want to keep. That's pretty user-hostile though - people generally don't like making choices that involve trashing a bunch of their newly created data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM