• 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: Directory navigated to by menu File > Open
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Directory navigated to by menu File > Open


  • Subject: Re: Directory navigated to by menu File > Open
  • From: Ken Thomases <email@hidden>
  • Date: Fri, 16 Jan 2015 23:34:00 -0600

On Jan 16, 2015, at 3:53 AM, Jerry Krinock <email@hidden> wrote:

> Also, I’d forgotten about -[NSSavePanel setDirectoryURL:].  TextEdit does not invoke this method, so that does not explain the behavior.  And yes I agree that overriding both -runModalOpenPanel:forTypes: and -beginOpenPanel:forTypes:completionHandler:, calling super, is even simpler and safer than re-implementing -openDocument:.
>
> So I tried that.  But it didn’t work either!  Not even in the TextEdit sample project.  The dialog always opens to either the default NSNavLastRootDirectory value, or ~/Documents, or TextEdit’s folder in iCloud Drive.

How about, instead of calling through to super, you simply implement those methods in the straightforward way by running the Open panel.  For -runModalOpenPanel:forTypes:, set the directoryURL as you want, set allowedFileTypes with the types array that was passed in, and call -runModal on the panel and return its result.  For -beginOpenPanel:forTypes:completionHandler:, set the same two properties and then call -beginWithCompletionHandler: on the panel with the passed-in completion handler.

The theory is that, if you call through to super, it will do the same thing except it will set the directoryURL to whatever it thinks is best, replacing the one you set in your override.  So, just don't give it that opportunity.

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Directory navigated to by menu File > Open
      • From: Jerry Krinock <email@hidden>
References: 
 >Directory navigated to by menu File > Open (From: Jerry Krinock <email@hidden>)
 >Re: Directory navigated to by menu File > Open (From: Quincey Morris <email@hidden>)
 >Re: Directory navigated to by menu File > Open (From: email@hidden)
 >Re: Directory navigated to by menu File > Open (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Using NSArrayController with a complex, heterogeneous model
  • Next by Date: Re: Using NSArrayController with a complex, heterogeneous model
  • Previous by thread: Re: Directory navigated to by menu File > Open
  • Next by thread: Re: Directory navigated to by menu File > Open
  • Index(es):
    • Date
    • Thread