• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Disappearing accessory view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Disappearing accessory view


  • Subject: Re: Disappearing accessory view
  • From: Michael McLaughlin <email@hidden>
  • Date: Thu, 18 May 2017 10:19:01 -0400

In my case, it is only a question of PDF or not (then PNG).  This is recorded in BOOL isPDF in the document which uses it later as a switch in its writeToURL method.  All of this seems to be working.  Am I wrong in thinking that this should be safe?

FWIW, I never reference the “allowedFileTypes” array in my code.  It exists only in the plist info.  Also, in my app, these two types are write-only.

On May 18, 2017, at 3:27 AM, Quincey Morris <email@hidden> wrote:

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.

--
Michael McLaughlin
email@hidden





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Disappearing accessory view (From: Michael McLaughlin <email@hidden>)

  • Prev by Date: Re: Disappearing accessory view
  • Next by Date: Re: Novice Struggling With Wrangling a Project Template Into Shape
  • Previous by thread: Re: Disappearing accessory view
  • Next by thread: Novice Struggling With Wrangling a Project Template Into Shape
  • Index(es):
    • Date
    • Thread