Re: NSUserdefaults shared by 2 applications, not synchronized ?
Re: NSUserdefaults shared by 2 applications, not synchronized ?
- Subject: Re: NSUserdefaults shared by 2 applications, not synchronized ?
- From: Bill Cheeseman <email@hidden>
- Date: Wed, 16 Feb 2005 17:50:53 -0500
on 2005-02-16 4:36 AM, Aurélien Hugelé at email@hidden
wrote:
> I have a GUI+Daemon application type, so it is in fact _2_ applications. The
> GUI App is used to modify some values, that are stored in the defaults.
> The daemon app read those values, and take them in account to do its job.
>
> I've used addSuiteNamed:@"com.MyApp.TheGUIPartOfMyApp" in the daemon app, so
> that the daemon can read the defaults of the GUI app. This works beautifully.
> But i must have missed something because once launched, the daemon can read
> the defaults of the GUI, but if i modify the defaults from the GUI, the daemon
> still get the OLD values, before they were modified...
As another poster suggested, just call -synchronize in the GUI app every
time it changes the shared settings.
I took it a step further in my app. My daemon is AppleScriptable and the
user can write scripts to tell it to change shared defaults. I wanted the
GUI app, if it was running at the time, to update its GUI automatically to
reflect the new settings, so I used Cocoa's NSDistributedNotificationCenter.
Every time either app writes to shared user defaults, the other app gets a
notification and immediately reads in the updated shared user defaults and
performs various operations to keep all settings and GUI in sync.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden