Re: Pass command line arguments to the app?
Re: Pass command line arguments to the app?
- Subject: Re: Pass command line arguments to the app?
- From: Chris Parker <email@hidden>
- Date: Thu, 17 Jul 2003 13:43:16 -0700
Hi Chad,
On Thursday, July 17, 2003, at 12:26 PM, Chad Armstrong wrote:
How is it possible to pass command line parameters from a Cocoa
application to the rest of the app? The main() function has the argc
and argv and passes those to NSApplication. How might my other
classes be able to access those arguments?
You can parse the command line arguments yourself by using
NSProcessInfo, or you can use NSUserDefaults and the argument domain.
If your command line is
MyApp -target filename.txt
Then
NSString * path = [[NSUserDefaults standardUserDefaults]
stringForKey:@"target"];
will let you pick out the named arguments on the command line. If you
don't have named arguments, then NSProcessInfo's -arguments method is
likely what you're after.
.chris
--
Chris Parker
Cocoa Frameworks
Apple Computer, Inc.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.