In my app, I am trying to do a simple thing – save a txt file and an image file into iCloud and then retrieve it back to open it on the app.
Right now, I can save both txt and image files into iCloud – no problem. I can even pull the URLs and the file names of the documents from iCloud – no problem there as well. But my question is, how do I open the txt file? What a sample code to open a txt file from iCloud and get the text contents? My txt file document is a subclass of UIDocument, if that helps.
well I notice it’s like 4 months after you asked this question. Maybe this will be help for other seeking souls here.
Basically, on iOS you open a UIDocument first by querying all documents, then by opening what iCloud responds you with.
Here’s how you start a query:
Before doing code above, subscribe to these notifications to receive response
Then in your response you can open the document
YourUIDocumentClassName *document = [[YourUIDocumentClassName alloc] initWithFileURL:documentURL];
You can check Apple’s session on icloud and UIDocument https://developer.apple.com/videos/wwdc/2012/?id=218
Hope it helps.