Thursday, 15 May 2014

ios - How to determine if the local file is newer when moving local files to iCloud? -



ios - How to determine if the local file is newer when moving local files to iCloud? -

when user enables icloud in app, need move local files icloud. here, utilize setubiquitous:itematurl:destinationurl:error: move each file. problem is, if (for local file) same file url exists on icloud, method fails.

my question is, how can determine file newer (local vs icloud) can either overwrite icloud version or discard local version each file? or, somehow forcefulness ios perform upload , set file state conflict on icloud conflict resolution methods take on , handle this?

fwiw, apple's dox suggest all-or-nothing icloud approach - i.e., inquire user @ 1 point whether or not icloud should enabled or not , don't change.

that said, situation i'd suggest next steps after user enables icloud:

1) run nsmetadataquery ubiquitous scope list of files in cloud app. (note query must run on main thread or nil back).

2) if have file of same name, can utilize lastly modified date key (nsmetadataitemfscontentchangedatekey) in nsmetadata figure out 1 should utilize (or whatever approach want utilize resolving conflict)

3) if file not in cloud, utilize setubiquitous method set there.

ios objective-c cocoa-touch icloud uidocument

No comments:

Post a Comment