How to integrate iCloud on a non Document-based app?
I’ve read the Apple docs and Ray Wenderlich’s tutorial. It seems that I’m forced to use UIDocument so I read it up in the docs. I’ve found that it’s effective to use Document-based approach.
My problem is I don’t want to be tied in techniques specific to the platform (iOS) thus my app has its own models made from scratch that only inherit from NSObject. This includes saving/loading.
Now, I need to integrate iCloud along with my old models. How will I do it in an elegant/effective way where I get to keep my old model implementation and be able to integrate iCloud?
Solutions Collect From Internet About “How to integrate iCloud on a non Document-based app?”
You are not in any way forced to use
UIDocument. You can use iCloud via
NSMetadataQuery. The general approach is:
When creating files
- Create the file locally, as normal without iCloud
-[NSFileManager setUbiquitous:itemAtURL:destinationURL:error:]to transfer the file to iCloud storage.
- (if necessary) Check on upload progress using
NSMetadataQueryor by polling URL resource values.
When opening files
NSMetadataQueryto locate iCloud-resident files
-[NSFileManager startDownloadingUbiquitousItemAtURL:error:]to begin download or to synchronize the local copy with the cloud copy.
- Check on upload progress using
NSMetadataQueryor by polling URL resource values with
When editing files
NSFileCoordinatorto coordinate your file access with the ubiquity daemon.
NSFilePresenterto get notifications of changes to files.
This is all covered in sessions from WWDC 2012 (and maybe 2011, I don’t recall), and the classes and methods you’ll need are all in the iOS documentation.
- switch case on NSString in objective c
- 2.23: Apps must follow the iOS Data Storage Guidelines or they will be rejected
- How can I make my level menu scrollable vertically?
- NSNotificationCenter removeObserver: in dealloc and thread-safety
- UDP broadcast using CFSocket on IOS
- Class variable defined at @implementation rather than @interface?
- swapping images using pan gesture
- how to make a view to look like the newsstand bookshelf
- iPhone Simulator 3.x not listed after upgrading to XCode 3.2.3 Beta4 with OS 4.0
- The “prefs” URL Scheme not woring in iOS 10 (Beta 1 & 2)
- UISearchBar Not shifting up
- Selector to get indexPath UICollectionView Swift 3.0
- Misaligned title in UINavigationBar since iOS6
- Even with “voip” present in “UIBackgroundModes” in “plist”, iOS App does not auto start after device reboot in iOS10
- UIButton events. What's the difference?