UIDocumentBrowserViewController doesn't call localizedName or honor shouldShowFileExtensions

85 Views Asked by At

I am using Xcode 14.2 on macOS Ventura 13.2, working on an iOS app initially created from Xcode's template via New Project > iOS > Document App. I am using Objective-C, not Swift. I am testing in the simulator's "iPad Pro (12.9 in) 6th Generation - iOS 16.2" module.

The template created a UIDocumentBrowserViewController subclass and a UIDocument subclass, which I've been filling in.

I have two problems.

First, the document browser is ignoring its own shouldShowFileExtensions property. I have it set to NO, and I have checked that it is still NO later during runtime; but the browser view still displays filename extensions.

Second, I'd really rather the browser displays the UIDocument.localizedName string instead of the filename. This is a read-only property of UIDocument which is supposedly overridable by the subclass to return whatever string you'd like. My UIDocument subclass's override is never being called.

The override looks like this:

- (NSString*)localizedName
{
    return [self projectName];
}

I am not doing anything weird with my subclasses; I've done my best to follow Apple's guidelines and documentation meticulously. My app will create documents that later appear in the browser, and which can be opened again and displayed, so the basics are working; but I have no control over the display name of the documents in the browser.

What am I doing wrong? Thanks in advance for any help.

1

There are 1 best solutions below

3
On BEST ANSWER

localizedName is not used by the document browser, or it would have to create a UIDocument for every file in the directories the user visits! This would have a huge performance impact. LocalizedName is only used, as explained in the documentation, to display the document’s name after it is open in error messages and the like.