Re: Most elegant way to process command-line arguments in Cocoa?
Re: Most elegant way to process command-line arguments in Cocoa?
- Subject: Re: Most elegant way to process command-line arguments in Cocoa?
- From: Chris Suter <email@hidden>
- Date: Thu, 8 Mar 2007 06:38:04 +1100
On 08/03/2007, at 6:26 AM, Diop Mercer wrote:
Hi. Is there a technique in Cocoa that someone can share that makes
processing command-line arguments as easy as in Perl?
For example, with this little bit of Perl code:
use Getopt::Std;
if (!getopts("f:t", \%args)) {
usage();
}
the following happens when you run your Perl script:
1. if -f<somestring> or -f <somestring> appears on the command line,
either is accepted. You can have a space after the argument or not,
your preference. Either way, <somestring> magically winds up in the
hash variable %args, specifically in the hash bucket $args{'f'}.
2. if -t appears on the command line, it's considered a switch, and
the hash bucket $args{'t'} gets set to 1.
Is there a Cocoa equivalent to this?
Command-line arguments to Cocoa end up as user defaults so you access
them via NSUserDefaults.
MyProg -MyArg <array><string>hello</string><string>there</string></
array>
well set a user default called MyArg to an array: { "hello", "there" }
Search the docs. for more information.
-Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden