I made an app which works with recorded files such as MP4 wave and so on.
I want to sync my app with iCloud but I don't know how.
Which method is better: Document-based, Key-Value pair or Core Data?
And also I have the following questions:
Consulting the Three Kinds of iCloud Storage section in the iCloud Design Guide gives us this:
iCloud supports three kinds of storage. To pick the right one (or combination) for your app, make sure you understand the intent and capabilities of each. The three kinds of iCloud storage are:
Key-value storage for discrete values, such as preferences, settings, and simple app state.
Document storage for user-visible file-based information such as word processing documents, drawings, and complex app state.
Core Data storage for shoebox-style apps and server-based, multi-device database solutions for structured content. iCloud Core Data storage is built on document storage and employs the same iCloud APIs.
So basically, it depends on what you want to do. The above paragraph is pretty self-explanatory and definitive, however if you still can't decide, read Designing for Key-Value Data in iCloud, Designing for Documents in iCloud and Designing for Core Data in iCloud to learn about the features and limitations of each option.
iCloud File Management should provide answers to your other questions.
You manage files located in iCloud document storage using the normal NSFileManager
methods, which means you can move, delete and copy files just as you would in local storage.
Unlike OS X, iOS does not have a Trash bin that deleted files are moved into. If you delete a file, it's gone. If you want trash functionality, you'll have to implement it yourself.
This guide describes how to discover files in your app's iCloud folder. The key line of code here is
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(processFiles:)
name:NSMetadataQueryDidUpdateNotification
object:nil];
The NSMetadataQueryDidUpdateNotification
is posted the metadata query updates. If you leave it running continuously, it will be posted every time a file changes externally, so you can take appropriate action. For more information on this, see the NSMetadataQuery
Class Reference.
I don't see why you would need to do this, since you can just get a list of files currently in iCloud when the app launches, and allow the user to edit them. There shouldn't be a reason why you need to know that the files have changed. However, if you really need to do this for some reason, you could probably save the relevant data returned by an NSMetadataQuery
locally, and then load that file when the app launches and compare the list you have saved to the list of files in iCloud, and use that to figure out what changed in the meantime.
Hopefully the number of documentation links in this answer demonstrates that all your questions were already answered.