• 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: prevent multiple instances of a program
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: prevent multiple instances of a program


  • Subject: Re: prevent multiple instances of a program
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 11 May 2011 16:18:29 -0500

On May 11, 2011, at 4:02 PM, Martin Batholdy wrote:

> My program consists of a menu item and is NSUIagent - so it is hidden in the Mac OS app-bar.

I'm not familiar with "NSUIagent" and search of the docs don't produce any hits.  Did you mean LSUIElement?  I also assume that "menu item" refers to a status item and that "Mac OS app-bar" means the Dock.  Using precise terminology is necessary for people to be able to help you.

> Now what surprises me is that I am able to open several instances of this program.
> Every time I click on the app-file a new symbol appears and I have a new instance of my program running.

Are you sure you have a new instance rather than just a second status item?  Does Activity Monitor show two processes for your app?

> How can I prevent this?
> (so that system-wide you can only have one instance of the program running)

You almost certainly mean "session-wide", not "system-wide", since other users can be logged in to other sessions via Fast User Switching.

Anyway, this is the default.  Launch Services will not normally launch a second instance of your app.  (The Finder uses Launch Services when you double-click an icon.)

So, I suspect that you are creating a second status item in response to the events and corresponding delegate method calls that occur when your app is double-clicked a second time.  In what method are you creating the status item?

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >prevent multiple instances of a program (From: Martin Batholdy <email@hidden>)

  • Prev by Date: Re: prevent multiple instances of a program
  • Next by Date: Cocoaheads Lake Forest meeting TONIGHT, 7pm, El Toro library
  • Previous by thread: Re: prevent multiple instances of a program
  • Next by thread: Cocoaheads Lake Forest meeting TONIGHT, 7pm, El Toro library
  • Index(es):
    • Date
    • Thread