3

I'v been reading through the Apple Docs, read through a couple tutorials online, and even watched the CS193p lectures on iCloud however there is still one thing I'm not clear about:

Take the case where you have an application that syncs documents to iCloud. How do you allow the user to still view/edit existing documents and create new documents while he/she is not able to reach the iCloud service (airplane mode, network not available, etc...)

For example. The 'reminder's application in iOS5 allows the user to view/edit existing documents that reside on iCloud even though you may be in airplane mode. The changes are then propagated the next time the iCloud service is available.

This seems really strange to me. How do you populate a list of reminders if your metadata query isn't provided a valid URL to a ubiquitous container? ie., calling URLForUbiquityContainerIdentifier: will return nil since iCloud is not available. Then creating a metadata query isn't possible because you can't provide it a URL to query on. Hence, you can't populate a list of documents for the user to view and edit offline.

Any help or insight to how this is done is greatly apprecaited!

====================================UPDATE====================================

Ok - I stumbled upon this thread: here

It's basically talking about how files are stored in the file system when using iCloud. From what I gather whenever a file is created on iCloud it's basically kept in a special extended local storage container that is created when you first call URLForUbiquityContainerIdentifier:. This special directory is managed by the iCloud deamon. In addition to being stored in this special directory the document is also uploaded to the cloud for use by other applications.

Now - assuming my assumption above is correct, the question is: If iCloud suddenly is not available, how do you access the files stored by the local daemon?

Community
  • 1
  • 1
Joey J
  • 1,355
  • 10
  • 26

1 Answers1

1

The answer to this question is related to this other question. You need to request the files you want to modify from iCloud so they download to the local UbiquityContainer which is available in offline mode. See this Questions Answer

Does URLForUbiquityContainerIdentifier: return nil when network access is not available?

All in all, the method URLForUbiquityContainerIdentifier: does not return nil when offline, just when iCloud is genuinely unavailable.

Community
  • 1
  • 1
MobileOverlord
  • 4,580
  • 3
  • 22
  • 30
  • I should also mention that NSFileManager can be blocking and should be called in a different thread from the main thread. http://stackoverflow.com/questions/9050359/should-urlforubiquitycontaineridentifier-be-called-in-a-thread-outside-the-main/9051105#9051105 – MobileOverlord Jan 29 '12 at 05:14