• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Pass command line arguments to the app?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Pass command line arguments to the app? (From: Chad Armstrong <email@hidden>)

  • Prev by Date: Re: cocoa/Obj-C API for iCal
  • Next by Date: Re: Pass command line arguments to the app?
  • Previous by thread: Pass command line arguments to the app?
  • Next by thread: Re: Pass command line arguments to the app?
  • Index(es):
    • Date
    • Thread