Directory navigated to by menu File > Open
Directory navigated to by menu File > Open
- Subject: Directory navigated to by menu File > Open
- From: Jerry Krinock <email@hidden>
- Date: Thu, 15 Jan 2015 16:16:02 -0800
I have noticed that the directory which is navigated to in the File > Open dialog of my NSDocument-based application does not give what I expect, and am trying to control it. To make sure it’s not due to something I did, I am experimenting with Apple’s TextEdit sample project instead.
Although the expected directory is not mentioned in the documentation of -[NSDocumentController openDocument:], -[NSDocumentController currentDirectory] is said to return “the directory path to be used as the starting point in the Open panel”. Furthermore, Apple’s implementation returns “the first valid directory from the following list:"
• The directory location where the current document was last saved
• The last directory visited in the Open panel
• The user’s home directory
So, great, I thought, just override -currentDirectory in the NSDocumentController subclass for TextEdit, and I can make it go wherever I want to.
But, no. Although my -currentDirectory override is invoked when I click menu > File > Open, any path I return seems to be ignored. If no document is open (no “current document”), it seems to always somehow remember and go to the directory of the last document that was opened, even if this was in a long-app application run. This is the case even if I delete the “recents” file ~/Library/Preferences/com.apple.TextEdit.LSSharedFileList.plist before launching. And no such path is shown when I run the command “defaults com.appleTextEdit”. The system must be remembering this path elsewhere.
Presumably I could get the control I want by overriding and re-implementing -openDocument: to actually use -currentDirectory the way the documentation says it should. It should be a lot less lines of code than I’ve written in this message. But before I do that I’m asking if anyone else has been here and done anything similar.
_______________________________________________
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