Cocoa Document Based Application question

Discussion in 'Mac Programming' started by Draque, Jan 6, 2015.

  1. Draque macrumors newbie

    Joined:
    Jan 6, 2015
    #1
    I've got a pretty basic question here about a Cocoa project that I'm working on through XCode. I'm using most of the basic setup/files that were provided to me by the IDE when it set the project up.

    The program that I'm making is essentially a glorified frontend, 90% of which is done at this point. The last element I need to do is to capture the filename of the associated file that was double clicked to start the application. I need to be able to pass the full path of the file along to the program I'm starting up with my application.

    It seems like this should be pretty simple, but I've been stumped so far. Could anyone lend a hand and let me know the code that could do that (and where it should live)? Thanks!
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Read about NSApplicationDelegate:
    https://developer.apple.com/library...nce/NSApplicationDelegate_Protocol/index.html

    It has methods that are called when files are passed to the app to be opened, printed, etc.

    Look on the left under the heading "Related Documentation" for detailed discussion and fundamentals. For example, "Mac App Programing Guide", in its "Core App Design" section.

    Also look there under the heading "Sample Code" for links to examples. It shouldn't be difficult to find one with an NSApplicationDelegate that implements one of the file-open callbacks.
     

Share This Page