0

I have a setup in which I have a single plist file that I need to be kept in sync between devices for a universal app. At present the plist file is stored in the documents directory.

I have been looking around online for ways to keep the file in sync and a lot of solutions seem to be based around Core Data. I'm not sure if it's possible, but is there a way I can just sync this one file without using Core data? If so, please can someone advise on how to approach the problem or point me in the direction of some materials that can assist?

To be more specific I need a way of ensuring that the device being used has the most up to date copy of the plist file. For example, if I edit it on my iPad at breakfast, then at lunch time I load the app on my iPhone I should see the edits made at breakfast time via my iPad.

2 Answers2

0

iCloud automatically backs up all the documents directories for all apps (or selective) on your device if you have iCloud Backup turned on in settings.

But the above things happen I guess once in a day. In order for it to work real time you will have to use iCloud API's.

Hoping this helps.

Ankit Srivastava
  • 12,347
  • 11
  • 63
  • 115
0

AFAIK you will require to provide the iPhone/iPad app with server APIs for making a POST request. You can POST the entire file or create POST request with body (JSON/XML) containing actual data from plist file. You will have to maintain ETag/Versioning information on the server. For synching to work, you need to identify each user uniquely on the server and store his plist information.

In the iPhone/iPad app during every app launch check for the resource ETag (in case file is uploaded) or for version (in case plist file contents were posted as XML/JSON) by making a HTTP request. You can also develop a scheduler functionality in the application for better precision. In case of update, download and save the new information/plist file. Keep entry for ETag/version in the application NSUserDefaults and update it during this process.

Friendly advice: Avoid storing any downloadable data/settings in Application_Home/Documents directory as app may get rejected. Please read this post and related documents on Apple's developer portal.

This is just initial thought, improvising and optimizing this is for you to figure out ... :)
I hope this helps!

Cheers!!
Amar.

Amar
  • 13,202
  • 7
  • 53
  • 71