Skip navigation.
 
mlRe: Command Line Arguments
FROM : Finlay Dobbie
DATE : Mon Apr 11 23:13:00 2005

On Apr 11, 2005 3:09 PM, Jason Whitehorn <jason.<email_removed>> wrote:
> I am a newbie when it comes to Cocoa programming, and am currently
> trying to figure out how command line arguments are passed to my
> program.


GUI applications do not generally take command line arguments.

> I have a program that I am trying to associate with a specific file
> type, and when I double click an associated file in Finder, I want my
> program to launch and do something with the file.


Except that the file is not passed on the command line. Instead, it is
handed an 'odoc' AppleEvent.

> When I attempt to
> read from argv I find something like "-psn_0_100401153" where I am use
> to expecting passed arguments. All I want is the path to the passed
> file. For example if I were to double click on "Test.file" on my
> Desktop, I would want the string "/Users/Jason/Desktop/Test.file".


You're assuming that opened files are passed as arguments. They're
not. The method for handling these events in Cocoa is to implement the
relevant delegate methods in NSApplication.

-- Finlay

Related mailsAuthorDate
mlCommand Line Arguments Jason Whitehorn Apr 11, 16:09
mlRe: Command Line Arguments Ondra Cada Apr 11, 16:30
mlRe: Command Line Arguments Dan Saul Apr 11, 18:16
mlRe: Command Line Arguments Finlay Dobbie Apr 11, 23:13