• 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 apply arguments to .app application while starting it on Terminal?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to apply arguments to .app application while starting it on Terminal?


  • Subject: Re: How to apply arguments to .app application while starting it on Terminal?
  • From: Uli Kusterer <email@hidden>
  • Date: Sat, 4 Aug 2007 18:21:17 +0200

On 04.08.2007, at 12:26, Sherm Pendley wrote:
The $64,000 dollar question is - why does your app need command- line arguments to begin with?

If you just want to open a file using your app, you can just tell the user to drag and drop the file onto your application's icon. Or if you want to do it from the command line, you can use the "open" command to do the same (see 'man open' for options how you can specify a document and an application). Your app will be told to open the file via Apple Events. In the case of a Cocoa app, NSApplication will send a message to its delegate about files it was told to open.


If you want to specify other settings, you should usually have some GUI (e.g. a Preferences panel in your app) to save these options in a preferences file, and have your app read them from there. You could also create a system PrefPane that will show up in "System Preferences" and have that edit the prefs file, if your application is essentially faceless.

There are literally dozens of ways to do it right, but I can think of only a few cases where command line parameters would be the way to go. If you tell us more about what your app does and what these parameters are needed for, we can probably point you at the right method to do this on a Mac. Also note that NSApplication generally processes command line parameters itself and writes them into the user defaults, that may interfere with your processing of them.

Cheers,
-- M. Uli Kusterer
http://www.zathras.de



_______________________________________________

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


  • Follow-Ups:
    • Re: How to apply arguments to .app application while starting it on Terminal?
      • From: Ryan Britton <email@hidden>
    • Re: How to apply arguments to .app application while starting it on Terminal?
      • From: Scott F Bayes <email@hidden>
References: 
 >FW: How to apply arguments to .app application while starting it on Terminal? (From: "Kan Cheng" <email@hidden>)
 >Re: How to apply arguments to .app application while starting it on Terminal? (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: NSNumberFormatter -setZeroSymbol:
  • Next by Date: Secure-Text-Field-Like Field Editor Initialization
  • Previous by thread: Re: How to apply arguments to .app application while starting it on Terminal?
  • Next by thread: Re: How to apply arguments to .app application while starting it on Terminal?
  • Index(es):
    • Date
    • Thread