0

The question is pretty obvious, but for me the answer is not quite..

So, I'd like to save (a) record(s) to CloudKit and I do, when internet connection let me to, but how to achieve this, when there is no wifi connection neither 3G/LTE, for example in 'Airplane mode'.

I do not want to refresh every 15/30 minutes, like fetching new mails, but to save when net connection comes back.

Any ideas, please?

Zsolt
  • 49
  • 8

1 Answers1

0

The only way to accomplish this is by saving the data locally an then syncing it the moment you have a connection. It depends on the type of data how you would store it on your device. what is the best structure for that. You could store it in CoreData or just in XML or some other file. You do need a synchronization mechanism for this.

You might want to check out this: Using Core Data, iCloud and CloudKit for syncing and backup and how it works together

Community
  • 1
  • 1
Edwin Vermeer
  • 13,017
  • 2
  • 34
  • 58
  • Yeah, I use Core Data, and I store the NSManagedObjects in a mutable array, but not sure where sholuld I invoke this method..Any suggestion? The method, which observes the net availability is in the AppDelegate, but the objects, which are waiting for the upload are in a different .m file. BTW, thanks for replying! – Zsolt Oct 14 '14 at 14:06
  • 1
    here is an article with more information about how to use it: http://www.atomicbird.com/blog/cloudkit-moves-like-azure and here is a step by step tutorial: http://timroadley.com/2012/04/03/core-data-in-icloud/ – Edwin Vermeer Oct 14 '14 at 15:12
  • I store all record deletions and changes into two arrays of CKRecordIDs and CKRecords . At an opportune moment (such as completing edits to a group) I try to synch these to CloudKit. If there is no connection available, I hold onto them and keep adding to the list. If the app needs to close I save these two files out (along with the present data for the app) and restore them on the next run of the app. – Peter Johnson Jan 14 '16 at 15:51