Re: Directory navigated to by menu File > Open
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