0

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 Answers1

0

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.

Thomas Deniau
  • 2,488
  • 1
  • 15
  • 15
  • Thanks. That does make perfect sense, and I'd wondered how that was supposed to work. Any thoughts about the shouldShowFileExtensions property? – Rick Holzgrafe Feb 14 '23 at 19:24
  • Also I wonder what use the localizedName really is, if that's all it's for. Why would I want to display a name in an error message that doesn't appear anywhere else? – Rick Holzgrafe Feb 14 '23 at 20:28
  • No idea about file extensions. localizedName just looks like a way to have a single method vending the name of the document for anything that needs to display it to the user once a UIDocument instance has been created. – Thomas Deniau Feb 16 '23 at 17:26