iphone - Syncing files with iCloud -


i made app works recorded files such mp4 wave , on.

i want sync app icloud don't know how.

which method better: document-based, key-value pair or core data?

and have following questions:

  1. can delete file? if so, go trash?
  2. can move file folder?
  3. how can know file changes?
  4. is there mechanism inform changes/creation/deletion happened while app closed?

consulting three kinds of icloud storage section in icloud design guide gives this:

icloud supports 3 kinds of storage. pick right 1 (or combination) app, make sure understand intent , capabilities of each. 3 kinds of icloud storage are:

key-value storage discrete values, such preferences, settings, , simple app state.

document storage user-visible file-based information such word processing documents, drawings, , complex app state.

core data storage shoebox-style apps , server-based, multi-device database solutions structured content. icloud core data storage built on document storage , employs same icloud apis.

so basically, depends on want do. above paragraph pretty self-explanatory , definitive, if still can't decide, read designing key-value data in icloud, designing documents in icloud , designing core data in icloud learn features , limitations of each option.


icloud file management should provide answers other questions.

1 & 2

you manage files located in icloud document storage using normal nsfilemanager methods, means can move, delete , copy files in local storage.

unlike os x, ios does not have trash bin deleted files moved into. if delete file, it's gone. if want trash functionality, you'll have implement yourself.

3

this guide describes how discover files in app's icloud folder. key line of code here is

[[nsnotificationcenter defaultcenter] addobserver:self     selector:@selector(processfiles:)     name:nsmetadataquerydidupdatenotification     object:nil]; 

the nsmetadataquerydidupdatenotification posted metadata query updates. if leave running continuously, posted every time file changes externally, can take appropriate action. more information on this, see nsmetadataquery class reference.

4

i don't see why need this, since can list of files in icloud when app launches, , allow user edit them. there shouldn't reason why need know files have changed. however, if need reason, save relevant data returned nsmetadataquery locally, , load file when app launches , compare list have saved list of files in icloud, , use figure out changed in meantime.


hopefully number of documentation links in answer demonstrates questions answered.


Comments