Welcome to Soft32 Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Single instance of application for each session

 
   Soft32 Home -> Mac -> Programmer Help RSS
Next:  Snow Leopard Migration Assistant Anomalies  
Author Message
kalpesh

External


Since: Sep 01, 2009
Posts: 3



(Msg. 1) Posted: Wed Sep 02, 2009 4:57 am
Post subject: Single instance of application for each session
Archived from groups: comp>sys>mac>programmer>help (more info?)

My application currently only allows one instance running by using
LSMultipleInstancesProhibited 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?

Can someone please help me out?
Back to top
Login to vote
Simon Slavin

External


Since: Dec 28, 2008
Posts: 37



(Msg. 2) Posted: Wed Sep 02, 2009 5:20 pm
Post subject: Re: Single instance of application for each session [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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
Back to top
Login to vote
cp

External


Since: Sep 02, 2009
Posts: 6



(Msg. 3) Posted: Wed Sep 02, 2009 10:59 pm
Post subject: Re: Single instance of application for each session [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

kalpesh <kalpeshgedia RemoveThis @gmail.com> wrote:

> My application currently only allows one instance running by using
> LSMultipleInstancesProhibited 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?
>
> Can someone please help me out?

That key exists for the exact situation you describe. A program cannot
run more than one copy per use in the first place. That key prevents it
from running for multiple users as well.

So, remove the key and it should work as you expect.
--
cp
Back to top
Login to vote
Display posts from previous:   
Related Topics:
NSWindowController - new instance ? - Hello NG In my application I have a subclass of NSWindowController ( articleBrowser). This class controlls a single..

NSApplication instance - Hello, does any one know whether it is possible to get the NSApplication instance of running applications? NSWorkspace....

Objective C++: unable to call function template instance - For some reason, this fails to compile with a linker error. It seems to have an "undefined symbol", without s...

How to notify event of one application to another applicat.. - Hi all Is there any way to catch click event when user open new folder? I want that my application runs in background....

How to check whether a application is running in xcode app.. - Hi, I am developing a application in objective c. I wanted to detect whether ical is running in my application.Can som...

Single movie to multiple windows? - It appears from the MovieGWorlds example on the Developer Connection website that I could draw the same movie..
       Soft32 Home -> Mac -> Programmer Help All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Categories:
 Windows
 Linux
  Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]