On Mar 8, 2010, at 9:17 AM, Arun wrote:

> Hi All,
> 
> What is the difference between the following two commands
> 
> 1.  open /Applications/TextEdit.app
> 2. /Applications/TextEdit.app/Contents/MacOS/TextEdit
> 
> Both launches TextEdit.app if i type both the commands in Terminal. Also in
> Leopard if i use "open" then i can't pass any program arguments to my cocoa
> app.
> So is there only one way (type 2) to pass command line arguments to cocoa
> app in Leopard

The ‘open’ command will do the same thing that double-clicking the app in the 
Finder would do, so if the app’s already open, it will simply bring that app to 
the front (and open a new document if there’s not already a window open). 
Executing the binary itself can lead to multiple instances of the same app 
being open.

Note that the ‘open’ command is just a wrapper around APIs provided by the 
system, so in a Cocoa app, it would make more sense to use those directly 
instead of fork/execing a command-line program. You can either use the 
LaunchServices APIs found in 
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Headers/LSOpen.h,
 or if you prefer a nice easy-to-use Objective-C wrapper, NSWorkspace has a 
decent number of openURL:, openFile:, and launchApplication: methods for you to 
choose from.

Charles_______________________________________________

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

Reply via email to