Re: Command line parameters...
Re: Command line parameters...
- Subject: Re: Command line parameters...
- From: glenn andreas <email@hidden>
- Date: Tue, 23 Aug 2005 16:37:39 -0500
On Aug 23, 2005, at 3:45 PM, Tom Harrington wrote:
On 8/22/05, Aaron Tuller <email@hidden> wrote:
At 3:53 PM -0400 8/22/05, Jeff LaMarche wrote:
Okay... I'm trying to build an objective-C foundation tool, and I'm
a little (okay, a lot) rusty on writing command line programs.
Do it the Cocoa way! Get your arguments like this:
NSArray *args = [[NSProcessInfo processInfo] arguments];
Ugh. OK, so it's Cocoa, but unless your needs are extremely basic,
this is just plain ugly. You'll end up writing a bunch of code to
validate the arguments and iterate through them, when the standard
Unix getopt(3) would give you all that for free.
Cocoa's usually great, but this is an exception to the rule. It's
convenience is misleading because it leaves you with so much extra to
do.
Look at NSUserDefault's NSArgumentDomain "consisting of defaults
parsed from the application's arguments".
Basically, command line arguments of the form "-foo bar" will be
automatically parsed for you to have a default named "foo" whose
value is "bar". It doesn't handle all the possible argument passing
styles, but it does give you a bunch for free (and may well be enough
for the original poster)
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | build, mutate, evolve | images, textures, backgrounds, art
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden