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

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

  1. macrumors newbie

    Joined:
    Feb 25, 2009
    #1
    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.

    Thanks.
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    I'm guessing [[NSDocumentController sharedDocumentController] currentDocument] would work.
     
  3. macrumors newbie

    Joined:
    Sep 6, 2009
    #3
    Hi,
    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