NSUserDefaults stickyness
NSUserDefaults stickyness
- Subject: NSUserDefaults stickyness
- From: Michael Peirce <email@hidden>
- Date: Thu, 14 Feb 2002 16:58:58 -0500
I've got an app which stores some data in it's user defaults (not an
uncommon thing I expect). To help me debug the app, I wrote a companion
app which reads the defaults and displays them for me to see in an
easily digestible format.
The first time I read the defaults everything is fine, but when I read
it later, after the first app has made changes, the data is stale.
The prefs file has been updated (I do use [[NSUserDefaults
standardUserDefaults] synchronize]) - when I view the data using
TextEdit, it's up to date, but my prefsWatcher app doesn't see it.
My code in the prefsWatcher looks like the following:
NSDictionary *prefsDict = [[NSUserDefaults standardUserDefaults]
persistentDomainForName: @"com.peircesw.myApp"];
It seems like the synchronize method is getting the updated prefs to be
written out to disk, but that my other app, doesn't know to reread them
from disk.
Here's what the docs say about synchronize:
Synchronizing an NSUserDefaults Object with the Defaults Database
Since other applications (and the user) can write to a defaults
database, the database and an NSUserDefaults object might not agree on
the value of a given default at all times. Using the synchronize method,
you can update the defaults database with an NSUserDefaults object's new
values and update the NSUserDefaults object with any changes that have
been made to the database. In applications in which a run-loop is
present, synchronize is automatically invoked at periodic intervals.
Consequently, you might synchronize before exiting a process, but
otherwise you shouldn't need to.
So it sounds like my case should be covered. Any ideas would I'd see
this behavior?
--
Michael Peirce
6497 Spinnaker Drive
Lewis Center OH 43035
740-657-1269
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.