Command Line Arguments for a Cocoa Application


#1

Hi,
I am developing both Command Line and GUI Applications in MAC based on Juce.
When the Executable is Launched from a Debugger (like XCode) WIthout Supplying any Command Line Arguments , The Number of Arguments obtained using argc is 1 and this is as Expected …
But when the Same is Launched from a Finder, I found ARGC to be 2 … Some thing like ./A.out -psn_0_XXXXX

My Code Launches either an UI/Command Line version based on the arguments Supplied … Some thing like

if(args > 1) launchCommandLine, else launchGUI

Due to this, When i Launch the Executable from Finder in MAC, it treats it as being launched with an Argument (args = 2) and so launches a command line version …
When Launched from XCode, everything goes fine …

How can i avoid this Problem and launch the UI version from Finder ?


#2

Yeah, I’ve no idea why it passes that -psn_xxxx parameter, or what it means! Just make your code look for the “-psn” and ignore it.