I am working on an app that is successfully saving and retrieving crossword files (writing them out in JSON) but currently only works with hardcoded file names.
I now want my user to be able to select files from the Documents folder, and I would like the UI to look a) good, and b) follow Apple's guidelines.
I tried using the UIDocumentPickerViewController, but this article seems to imply that it only works with files that are external to the sandbox.
With the code below, I just end up seeing a Downloads folder.
What's the right way to let the user see the contents of their Documents folder, so they can pick a file from it? I could read the contents and put them in a table view, but the UIDocumentPickerView's view looks (of course) very polished.
Thanks for any help!
I now want my user to be able to select files from the Documents folder, and I would like the UI to look a) good, and b) follow Apple's guidelines.
I tried using the UIDocumentPickerViewController, but this article seems to imply that it only works with files that are external to the sandbox.
With the code below, I just end up seeing a Downloads folder.
Code Block let documentPicker = UIDocumentPickerViewController(documentTypes: ["public.item", "public.data"], in: .im) documentPicker.delegate = self documentPicker.modalPresentationStyle = .formSheet documentPicker.directoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMasks[0] print(documentPicker.directoryURL) // yup, this is right self.present(documentPicker, animated: true)
What's the right way to let the user see the contents of their Documents folder, so they can pick a file from it? I could read the contents and put them in a table view, but the UIDocumentPickerView's view looks (of course) very polished.
Thanks for any help!