Re: Add Preference Pane for Background-only app
Re: Add Preference Pane for Background-only app
- Subject: Re: Add Preference Pane for Background-only app
- From: Gregory Weston <email@hidden>
- Date: Fri, 18 May 2007 07:15:49 -0400
Kam Dahlin wrote:
I have a Background-Only application that is started as a user login
item. This is working great, but I would like to add a simple System
Preferences pane to control some specific behavior of the background
app. I am looking for some advice or maybe the location of a few
online examples that could help me achieve this?
It's fairly straightforward. Just have your preference pane write to
the background app's defaults using and use
NSDistributedNotificationCenter to signal to the background app that
the defaults have changed.
Somewhere in the startup code for the backgrounder ...
NSNotificationCenter* theCenter = [NSDistributedNotificationCenter
defaultCenter];
[theCenter addObserver:self selector:@selector(doReloadPrefs:)
name:CompostNotificationReloadPrefs
object:[[NSBundle mainBundle] bundleIdentifier]];
and ...
- (void)doReloadPrefs:(NSNotification*)inNotification
{
// Make sure we're all up-to-date.
[[NSUserDefaults standardUserDefaults] synchronize];
}
The prefPane just has to finish the code that modifies the prefs
with ...
NSDistributedNotificationCenter* theCenter =
[NSDistributedNotificationCenter defaultCenter];
[theCenter postNotificationName:@"ReloadPrefs" object:myAppSignature
userInfo:NULL deliverImmediately:YES];
G
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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