Mac OS X provides no user interface other than Terminal for users to
specify command-line arguments. There's simply no way for a user to
provide that info.
then how is XCode doing it, when i set the 'arguments' for my project?
This is a question more appropos to xcode-users, but I'll answer
anyway :). Xcode's pseudo-terminal execution environment, both the
basic Run command and the gdb shell of the Debug command, runs the
command through something similar to this Terminal process:
$ cd /path/to/app/bundle
$ ./Application.app/Contents/MacOS/Application <the arguments you
specified>
Users can't do this except by using Terminal themselves. Users
shouldn't do this unless your application is specifically designed to
be used from Terminal. Command-line arguments simply aren't supposed
to be used in GUI programs under MacOS. (Though you'll find plenty
that do in the Windows and X11 worlds). It's not user-friendly. I
can't imagine why you'd want to do this. If you want to supply
configuration options, use preferences. If you want your app to do
different things based on which version a user downloaded, make that
determination via your own Info.plist key or some other mechanism. To
the best of my knowledge, there's no rule against putting your own
key/value pairs in an Info.plist as long as they don't conflict with
the Apple ones (a Java-style reverse DNS naming scheme such as
com.mycompany.mykey is definitely recommended for that, though I have
personally found that a unique two-character prefix which is not
"NS", "CF", or "LS" suffices and is easier to type :). Also,
commandline arguments aren't reliable. Terminal users won't get the
ones you define, you can't do it directly via Info.plist, and if you
could, powerusers have a tendency to play with commandline arguments
when they see them and you're inviting confusion at best that way.
Argc/argv were and are a great way to alter a CLI program's behavior,
but this is the GUI age and a GUI OS. The commandline is pure
gibberish to the majority of Mac users, in my experience. Don't get
caught in the idea that you have to do it that way just because you
always have :)
For the record, one way to actually do what you want would be to
write a tiny wrapper program as your CFBundleExecutable that does
this (written in Mail.app, standard disclaimers apply):
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden