How Do I get a reference to the openDocument method in first responder

Discussion in 'Mac Programming' started by tmeehan, Feb 25, 2009.

  1. tmeehan macrumors newbie

    Feb 25, 2009
    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.

  2. kainjow Moderator emeritus


    Jun 15, 2000
    I'm guessing [[NSDocumentController sharedDocumentController] currentDocument] would work.
  3. Gargantua macrumors newbie

    Sep 6, 2009
    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

Share This Page