Search code examples
iosswiftuidocumentbrowservc

Adding file extensions to iOS document manager


I’m using the default iOS file manager for a Swift application. I’m writing the class for a UIDocumentBrowserViewController and I want the whole file name to show. For example rather than Untitled, I want Untitled.txt. Or rather than script, script.py.

As a side note, I notice that the actual files app does not have functionality to show the extension.


Solution

  • Sometimes its worth to check apple documentation) https://developer.apple.com/documentation/uikit/uidocumentbrowserviewcontroller

    As I see it is possible to show file's extension, with help of var shouldShowFileExtensions: Bool from UIDocumentBrowserViewController. But to our sorrow it's available only from iOS 13.0+.

    And as Apple says about this property https://developer.apple.com/documentation/uikit/uidocumentbrowserviewcontroller/3153159-shouldshowfileextensions

    The default value is false.

    This property has no effect in iPad apps running in macOS.