On May 17, 2017, at 13:39 , Michael McLaughlin <
email@hidden> wrote:
As was probably obvious to everyone but me, I discovered that I did not need to save the NSSavePanel even though it is required to change the filetype and extension.
In fact, I suggest you don’t use an accessory panel for this at all. The larger problem is that NSSavePanel is extremely unreliable when you try to select a file type (and corresponding extension) in the dialog via the accessory view.
For example, if the user suppresses display of extensions, you might end up with surprising behavior when the user chooses the file type. It’s really, really hard (perhaps impossible) to keep the text field in sync with the accessory view type selection. In the worst case, the dialog might validate the pre-existence of the *wrong* file, possibly leading you to overwrite another file the user did not intend to overwrite.
The reason the behavior is unsatisfactory is historical. The various functional changes over the years, especially relating to sandboxed NSSavePanels (even if you’re not sandboxed), have taken away pretty much the ability to do this right. IIRC, it used to be possible, once upon a time, to provide a popup of formats that were tied directly to the “allowedFileTypes” array, but this is now gone.
Instead, if you have a couple of export types, it’s much safer to put one menu item for each on a submenu of an “Export” item on the “File” menu. If you have many export types, or the export types have their own parameters, I suggest using a preliminary dialog to choose the type, then a NSSavePanel that knows the one, correct type chosen for the export.