• 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: launching 2 same applications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: launching 2 same applications


  • Subject: Re: launching 2 same applications
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Fri, 10 Oct 2003 14:47:31 +0200

At 22:07 Uhr +0000 09.10.2003, Sean Liong wrote:
So if saying that if I call a dialog when found that the application is not running a desire path and ask the user that he should run the application like for example /Application/xx.app. It is not that "straightFoward".

Could you re-phrase? You can tell the user in a dialog window ("application-modal panel" in Cocoa parlance) not to launch the application from the USB media and just leave it to the user to remember where they put their copy. You can also suggest to them in the dialog to copy the application into /Applications, and you can ever to copy the application there for them before you quit the copy on the USB thingie.

However, if you want to be nicer to your users, you can also try to look for an existing copy of your application using LaunchServices. Since on the Mac, the user is allowed to put applications outside the /Applications folder (and many users do so), it would be very annoying to *require* the application to be in /Applications.

What is the main purpose of LaunchServices when compare to API in NSWorkspace?

NSWorkspace is mainly a NeXT holdover, I think. Most of its functionality is still current, but the code it uses to look for an application simply looks for applications in the different /Applications folders. This is useful in itself, but LaunchServices is more flexible, and more user-friendly. And user-friendliness is what Mac OS is all about, after all.

I used NSTask for launching application.

Bad Idea(tm). NSTask is intended mainly for running command-line tools. If you're dealing with a real, packaged ("bundled") application, you'll really want to use NSWorkspace's launchApplication method. NSTask is only a good choice if you want to send input to a command-line tool via Stdin or capture its output via Stdout. At least as far as I know. You can also use mach ports, NSPipes, Apple Events, Distributed Objects, NSDistributedNotificationCenters(?) and other such things to communicate between Mac applications, which is more flexible. But if all you want to do is launch one application and quit the one that launched it, launchApplication is the one you want.

In the begining of the application, I called NSTask to launch other different application and quit (no problem). But I cannot quit the application itself if it is launching the same program.

NSTask works synchronously, IIRC. It may even make the launched application a child of your current application, which means an application launched using NSTask will quit when your application quits. This is very useful when you have an application that functions as a GUI to a command-line tool, but is probably not what you wanted. Use NSWorkspace, which pretty much hands off the actual act of launching the other app to the Finder.

In windows, mfc program, I saw application just return false at the main function (quit eventually) and there is no problem launching the same program from another path

This definitely works on the Mac as well. You just have to use the right wrench to pound in the correct screw ;-)
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >Re: launching 2 same applications (From: "Sean Liong" <email@hidden>)

  • Prev by Date: Re: Editing Graphics
  • Next by Date: Re: Getting the version of a non-bundle carbon application
  • Previous by thread: Re: launching 2 same applications
  • Next by thread: Re: launching 2 same applications
  • Index(es):
    • Date
    • Thread