preferred file name extension for exported file type

Our app exports a number of file types in info.plist. For each of these file types, we export various possible file name extensions. For example, for one of our file types, we specify the possible extensions ".data", ".fitdat", and ".profitdata".

In the settings of our app, we allow the user to select their preferred extension to be used, i.e. the extension to be used when, e.g., saving a document with "Save As..." panel without explicitly specifying the extension.

For this, we override NSDocument's fileNameExtensionForType:saveOperation to return the presently preferred extension.

This has stopped working, probably starting from macOS 14. If the user does not specify the extension in the NSSavePanel, it's always the first extension (".data") that gets added to the file name.

I guess it's a consequence of the introduction of UTType, which has its own preferredFilenameExtension, which in turn probably just grabs the first extension we specify in our info.plist

Any advice how to resolve this? Is there any way to override NSSavePanel's selection of extension if the user does not specify one?

Thanks for any advice in advance

Kurt

In Mac OS 15 (Sequoia) if you set NSSavePanel.nameFieldStringValue to a filename with the desired extension, e.g. "foo.fitdat", then the save panel will use that extension instead of the preferred extension.

Please use Feedback Assistant to file a bug on NSSavePanel not using NSDocument's fileNameExtensionForType:saveOperation:.

preferred file name extension for exported file type
 
 
Q