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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com