• 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: How to pass command line parameters to Cocoa App
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to pass command line parameters to Cocoa App


  • Subject: Re: How to pass command line parameters to Cocoa App
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 16 Aug 2011 09:34:34 -0700

On Aug 16, 2011, at 7:54 AM, Abdul Sowayan wrote:

> If I launch my app from the command line, I can pass it options like this
> (this would be the argc, argv parameters to main):
> ./Foo.app/Contents/MacOS/Foo -ApplePersistenceIgnoreState YES

This is basically a convenience for development, so you can set custom configuration info when running your app from Xcode. It’s not a feature to use in a shipping app. You have no control over the argv values sent to an app when it’s launched normally.

> What I would like to have is launch my application from the GUI and somehow
> pass the command line parameters to it. If I had to guess, this would be
> encoded in the Info.plist file in the bundle. It is not clear to me how to
> do that. Any feedback would be greatly appreciated.

No, the Info.plist is read-only and only contains hard-coded settings.

What you’re probably looking for is AppleEvents. LaunchServices lets you launch an app and send a custom AppleEvent to it at launch time. The app can then receive the event and do whatever it wants with it. Read the LaunchServices docs for more info.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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

References: 
 >How to pass command line parameters to Cocoa App (From: Abdul Sowayan <email@hidden>)

  • Prev by Date: Re: recomendations for creating a beta with date to expire
  • Next by Date: Exact behavior of NSLiteralSearch in string compare?
  • Previous by thread: Re: How to pass command line parameters to Cocoa App
  • Next by thread: Re: How to pass command line parameters to Cocoa App
  • Index(es):
    • Date
    • Thread