• 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: Switching between background <-> foreground app type at run-time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Switching between background <-> foreground app type at run-time


  • Subject: Re: Switching between background <-> foreground app type at run-time
  • From: Mike Blaguszewski <email@hidden>
  • Date: Wed, 26 Sep 2007 14:24:12 -0400

On Sep 26, 2007, at 2:06 PM, vance wrote:

How do I switch between BackgroundOnly (has no doc icon and menu) and Foreground (has dock icon and menu) application at runtime, both ways?
Basically you can't. Your summary of the options is pretty accurate.

1. Setting LSBackgroundOnly or LSUIElement in Info.plist to "1" makes the application without a dock icon and menu.
I think this is the most reasonable solution, assuming your configuration UI is relatively simple (single window). Make your application an LSUIElement app (not LSBackgroundOnly) that uses NSStatusItem. You can then bring up a window just like in any Cocoa app, you just won't get a Dock icon or menu bar. I believe copy/paste/ etc. even work, but I can't remember for sure.

3. Have 2 different applications: One with LSBackgroundOnly set to 1, that creates the status item and Another one without
A variant on this is to have your NSStatusItem app set as LSUIElement, and your non-background app be inside the main app's bundle. Just add another target to your Xcode project, and it should be reasonable to manage. You can do IPC using NSUserDefaults, - [NSUserDefaults synchronize], and either watch for the NSWorkspace notification that the GUI app has quit, or have the GUI app send an NSDistributedNotification to tell the background app to resync its prefs. (You may need to drop down to CFPreferences API to share the user defaults this way.)

--
Mike Blaguszewski / Cocoa Hacker / Ambrosia Software, Inc.



_______________________________________________

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: 
 >Switching between background <-> foreground app type at run-time (From: vance <email@hidden>)

  • Prev by Date: Re: Switching between background <-> foreground app type at run-time
  • Next by Date: Re: creating classes on the fly ??
  • Previous by thread: Re: Switching between background <-> foreground app type at run-time
  • Next by thread: Re: Switching between background <-> foreground app type at run-time
  • Index(es):
    • Date
    • Thread