On Jan 16, 2015, at 3:53 AM, Jerry Krinock <[email protected]> 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 protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to