On 09-02-2009, kalpesh <kalpeshgedia.TakeThisOut@gmail.com> wrote:
> My application currently only allows one instance running by
> usingLSMultipleInstancesProhibited to true.
> However, when I use the fast user switching, the other user will not
> be able to launch the application even though they are on different
> session because of LSMultipleInstancesProhibited. So now, if I want
to
> support fast user switching, and have my application running only one
> instance for each session, what is the proper way to do it in cocoa?
The proper way to do this is not to prohibit multiple instances. You
have explicitly barred this yourself so naturally the OS won't allow
two users to run your application at once.
If you want to stop one user from using your application twice you
might use the 'defaults' mechanism (NSUserDefaults), since this stores
settings in one place per user. Use a particular setting as a flag
that your application is already running. You will have to cope with
the rare situation of a force-quit, though: it's possible for the user
to quit your application without giving it a chance to reset its flag.
If this won't work for your application it might be best to explain
what you're trying to achieve by preventing a second instance. That
way we can advise you on good ways to do it.
--
I'm trying a new usenet client for Mac, Nemo OS X, since 0 days.
You can download it at
http://www.malcom-mac.com/nemo