iCloud and non-UIDocument files

98 views Asked by At

My app reads and writes audio files, using AVFoundation’s methods for file operation.

I would like to incorporate iCloud sync, with the intended outcome of having my app’s entire root Documents directory synced to the cloud.

I’m not really sure how to implement this. The Apple documentation says that iCloud syncing is free with files managed by UIDocument and that NSFileCoordinator needs to be implemented for all other file operations.

Do I need to somehow ‘wrap’ AVPlayer and AVRecorder’s file reading and creation calls in that file coordinator?

1

There are 1 answers

0
Alexander Kradenkov On

In case of UIDocument you may get NSData after it is opened. Saving the data by UIDocument also convenient. This approach is preferable, IMHO.

In case of NSFileCoordination you should implement also NSFilePresenter protocol in the wrapper object of resource.

Also, you may use NSFileManager for download state handling and resource availability verification. Also, you may place your local files in iCloud by - (BOOL)setUbiquitous:(BOOL)flag itemAtURL:(NSURL *)url destinationURL:(NSURL *)destinationURL error:(NSError **)errorOut. In this case you handle synchronization process by yourself.