James
James

Reputation: 18379

open a file of any type in ios, swift

I have a Swift based iOS app, and need to be able to open a file of any file type. I tried,

let types = UTType.types(tag: "*", tagClass: UTTagClass.filenameExtension, conformingTo: nil)
let modelPicker = UIDocumentPickerViewController(forOpeningContentTypes: types)

But does not work... How to allow any file type?

Code that worked was,

let types = [UTType.item]
let modelPicker = UIDocumentPickerViewController(forOpeningContentTypes: types)

Upvotes: 0

Views: 810

Answers (1)

Rob Napier
Rob Napier

Reputation: 299265

You very likely want UITType.item here (which is the identifier public.item).

A generic base type for most objects, such as files or directories.

You should spend some time looking over the docs for Uniform Type Identifiers. You may find other types that more closely match your intention.

Upvotes: 1

Related Questions