View Full Version : How Do I get a reference to the openDocument method in first responder

Feb 25, 2009, 12:33 PM
I have been programming on the mac for many years but I am quite new to interface builder and cocoa. My question is probably quite simple to answer.

I have a button that is used to bring up the file selection dialog to choose a file. I've created the connection between my button and the first responder's openDocument method. Everything works fine.... I click the button and up comes the file selection dialog. BUT how do I get a reference to the document that was selected. I would imagine that there must be an NSDocument object being created - maybe not.

What am I missing. Any help with this would be greatly appreciated.


Feb 25, 2009, 01:50 PM
I'm guessing [[NSDocumentController sharedDocumentController] currentDocument] would work.

Feb 16, 2012, 07:12 AM
I got the same problem and stumbled into this almost three year old thread.
Did you make any progress?

Ok, I could use NSFileManager or NSWorkspace. But using this build-in OpenDocument seems to be a nice and elegant way to do this.

Greetings, Ronald