iosmacoscocoaicloudnsfilecoordinator

iCloud & Shoebox Apps: How to atomically sync a file package?


I have a "Shoebox" Mac app with a UIDocument based iOS counterpart.

I'm trying to figure out the best strategy to synchronize data between Mac and iOS via iCloud.

I can't adopt NSDocument in the Mac app (it's a shoebox app without the concept of separate documents similar to albums in iTunes).

My plan for the Mac app is this:

For the iOS app:

My questions:


Solution

  • You're in for a world of heck, here. There's no magic bullet to synchronizing file packages between machines—there are too many unsolved problems that iCloud syncing glosses over. What happens when half the data files in your package write out and then the user shuts off her computer and the rest don't write? What if the main index file is read from the net correctly but the net fails before any of the data files it refers to are loaded?

    As far as I know iCloud doesn't do anything to deal with these kinds of issues.

    But, that said, even with a shoebox app I would (and did) use NSDocument. It's not very much work to get it to do what you want, and you get so much stuff for free. Like, just rip the "open" and "save" menu items out of your main menu, and tell the NSDocumentController to open your data file when the app launches. That's what we do.