2

I want to show a file picker for choosing a "save to file" location on iOS. The UIDocumentViewPickerController offers the method initWithURL:inMode: (https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller/1618684-initwithurl?language=objc) for saving files but it requires an url to a local file. Instead I want to get a file handle to which the data is written after picking. Does iOS offer such a function, or do I have to create a temporary local file first and then use the initWithURL method?

Regards,

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Hyndrix
  • 4,282
  • 7
  • 41
  • 82

1 Answers1

3

iOS 13 offers means for picking directories (https://developer.apple.com/documentation/uikit/view_controllers/providing_access_to_directories). It is possible to create new items as well.

// Create a document picker for directories.
let documentPicker =
    UIDocumentPickerViewController(documentTypes: [kUTTypeFolder as String],
                                   in: .open)
Hyndrix
  • 4,282
  • 7
  • 41
  • 82