• 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: Messaging Cocoa apps through Terminal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Messaging Cocoa apps through Terminal


  • Subject: Re: Messaging Cocoa apps through Terminal
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 3 Mar 2010 10:26:03 -0600

On Mar 3, 2010, at 10:17 AM, Ulai Beekam wrote:

> How can I send messages to my Cocoa app through the terminal? Say something like
> MyGreatMp3Player.app --sendAdvancedMessageThatIsNotInTheUI create100EmptyPlaylists
> I suppose it's hard to do this on the .app since it's just a directory, but you get the point. Just so the user (but mainly the developer for testing purposes) can somehow make the app do things that cannot be done in the UI.
> In the example above, the app is being asked to create 100 empty playlists, which could be useful to make sure that, say, the scrollbars are working well, etc.
> How could I do something like this? First: How do I send messages to the app? And second: How do I make my app detect these messages? Could I somehow do this with NSNotificationCenter?

You _could_ use NSDistributedNotificationCenter from a custom-built Foundation tool, but that's not really the right way to go about it.

What you need to do is make your app scriptable.
http://developer.apple.com/documentation/Cocoa/Conceptual/Scriptability/

Once it's scriptable, you can run an AppleScript script from the command line using osascript.
http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/man1/osascript.1.html

Cheers,
Ken

_______________________________________________

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: 
 >Messaging Cocoa apps through Terminal (From: Ulai Beekam <email@hidden>)

  • Prev by Date: Messaging Cocoa apps through Terminal
  • Next by Date: Re: Trying to achieve aperture PopUp buttons
  • Previous by thread: Messaging Cocoa apps through Terminal
  • Next by thread: Re: Messaging Cocoa apps through Terminal
  • Index(es):
    • Date
    • Thread