Questions tagged [uidocument]

UIDocument represents a user-editable document in an iOS application. It is an abstract base class in the UIKit framework. When it is used, its subclass takes the role of the model of a model-view-controller application. Because it implements the NSFilePresenter protocol, it significantly simplifies writing a document-based iOS application. Its Mac OS counterpart is NSDocument.

UIDocument represents a user-editable document in an iOS () application. It is an abstract base class in the UIKit () framework. When it is used, its subclass takes the role of the model of a model-view-controller application. Because it implements the NSFilePresenter protocol, it significantly simplifies writing a document-based iOS application. Its Mac OS () counterpart is NSDocument ().

To learn more, see the Document-Based App Programming Guide for iOS.

268 questions
3
votes
3 answers

Proper way to detect deletion of documents in iCloud across devices?

I can't find an obvious way to detect deletion of a document that I'm monitoring (I cache a list of docs my app cares about). On Device1: When I delete a doc, I call [fileCoordinator coordinateWritingItemAtURL:fileURL…
ski_squaw
  • 972
  • 1
  • 11
  • 21
2
votes
1 answer

iCloud daemon slow to upload changes that were done offline

The iCloud daemon seems to upload changes within a few seconds to the iCloud server when changes are made when the device is online. However, I've notice that when changes are done offline to the local iCloud container and then the device goes…
frilla
  • 1,773
  • 3
  • 11
  • 8
2
votes
4 answers

UIDocument couldn't close again?

When a UIDocument is closed, can it close again? Even when it's documentState is UIDocumentStateNormal after reopened? Please help me. Thanks a lot! [document openWithCompletionHandler:^(BOOL success) { if (success) { [document…
fengyuxx
  • 58
  • 6
2
votes
2 answers

How to interpret document.state == 12 (iCloud)

Whenever I load a UIDocument from iCloud, I check its state like so: NSLog(@"Library loadFromContents: state = %d", self.documentState); In some cases I have received documentState 8 or 12 which have caused crashes. I am now wondering what exactly…
n.evermind
  • 11,944
  • 19
  • 78
  • 122
2
votes
0 answers

iCloud Drive: NSDocument.revert(toContentsOf:ofType:) called when document is merely opened on another device

I have a macOS and iOS app, based on NSDocument and UIDocument respectively. They synchronize their documents via iCloud Drive. I noticed that NSDocument.revert(toContentsOf:ofType:) is called on the Mac when a document is merely opened in the iOS…
Mark
  • 6,647
  • 1
  • 45
  • 88
2
votes
0 answers

How to use iOS security scoped bookmarks across devices?

On iOS (14/15) I'm trying to pass security scoped bookmarks to user picked files on iCloud Drive between devices but whatever I try: I cannot get urls to be restored on another device running the same app. The app is a UIDocument based app, the code…
Gerrit Beuze
  • 903
  • 2
  • 10
  • 26
2
votes
1 answer

how to initalise UIDocumentPickerViewController noting "forOpeningContentTypes" (from doco) seems to be deprecated in IOS?

When following the onsite IOS documentation for UIDocumentPickerViewController in Xcode 12.5.1 with IOS 14.5 deployment target I get an error: Incorrect argument label in call (have 'forOpeningContentTypes:', expected 'forExporting:') Any advice on…
Greg
  • 34,042
  • 79
  • 253
  • 454
2
votes
1 answer

How to avoid strange behavior when scene-based document mac catalyst app reopens windows on app restart?

I have been struggling to get the mac version of a mac catalyst app to work. This is a scene-based, DocumentBrowserViewController based app that works fine on the iPad. On the Mac, it works fine, except if you close the app when one or more…
2
votes
0 answers

How to close the UIDocument and save data when user quits the app in Mac Catalyst

I have a document browser based iOS app that also works on Mac with Catalyst and there seems to be a problem with saving the document data when the user quits the app (e.g. by pressing command+q). I am trying to close the document gracefully as soon…
JanPr
  • 21
  • 1
2
votes
0 answers

Displaying UIDocuments in Files App iOS 13

I'm trying to integrate my application with the Files App so that documents saved in my application are showed in the Files App, either under the 'iCloud Drive' or 'On My iPhone' folders. I've added the following keys the info.plist…
Danny Bravo
  • 4,534
  • 1
  • 25
  • 43
2
votes
1 answer

I can write iCloud Documents, but cannot see them

A am working with UIDocuments and iCloud. I am successfully able to write out a file to iCloud but not seeing in on the device and the files app. I have the following in info.plist. NSUbiquitousContainers
jz_
  • 338
  • 2
  • 14
2
votes
2 answers

UIDocumentBrowserViewController.revealDocument not working as expected

The issue involves sharing a document with my app using the "Copy to ...". The result of that action is a call to: //TODO: This is where we save to the documents folder I beleive. func application(_ app: UIApplication, open inputURL: URL,…
hidden-username
  • 2,610
  • 3
  • 14
  • 19
2
votes
1 answer

Is it possible to use Core Data in a document-based application?

I'm working on an iOS app that will need to save data onto files. I chose to go for a Document Based app, precisely an app based on a UIDocumentBrowserViewController so that I can easily save and load files from the system's Files app. Since the…
Clément Cardonnel
  • 4,232
  • 3
  • 29
  • 36
2
votes
1 answer

How can i get the original file name using UIDocumentPickerViewController?

I need to know the type of file that I want to import. I can find out the type from the file name for PHAsset you can use the following method: Attachment *attachment = [[Attachment alloc] init]; …
2
votes
0 answers

Saving and loading UIDocumentBrowserViewController

I know I can encode/decode my files for saving/loading at my UIDocument from UIDocumentBrowserViewController using the code below, as explained on Apple's 2017 WWDC. class Document: UIDocument { override func contents(forType typeName: String)…