Re: NSUserDefaults and the synchronize: method - doesn't seem to sync...
Re: NSUserDefaults and the synchronize: method - doesn't seem to sync...
- Subject: Re: NSUserDefaults and the synchronize: method - doesn't seem to sync...
- From: Chris Parker <email@hidden>
- Date: Mon, 3 Dec 2001 11:29:21 -0800
Diggory -
It sounds like you're assuming that the stuff you get back from
persistentDomainForName: is mutable - persistentDomainForName: is
defined to return an NSDictionary.
If you really want to do this, the way to do it is to pick up the domain
with persistentDomainForName (or just get it as a dictionary right off
the disk), make a mutable copy of the dictionary, and make your changes
to that.
Then, use setPersistentDomain:forName: to make your mutable dictionary
the domain and sync defaults against that (I just tried something
similar to this and it works fine).
If you're working with the IC preferences, I would highly recommend
using the IC API.
.chris
On Sunday, December 2, 2001, at 07:17 AM, Diggory Laycock wrote:
I'm writing an object that interacts with the Internet Config defaults
(found in the file com.apple.internetconfig.plist)
I have got the standardUserDefaults object and have used
persistentDomainForName:
to get an NSMutableDictionary (internetDefaults) that represents the
propertylist.
I can extract info from this dictionary fine, but when I change an
object deep in the dictionary this change doesn't seem to pass into the
actual defaults system (or the plist file).
The change doesn't seem to pass into the file even if i pass the
synchronize:
message to the standardDefaults object (which the docs seem to suggest
isn'
t even necessary.)
<from the NSUserDefaults docs:>
synchronize
- (BOOL)synchronize
Saves any modifications to the persistent domains and updates all
persistent domains that were not modified to what is on disk. Returns
NO if it could not save data to disk. Because synchronize is
automatically invoked at periodic intervals, use this method only if
you cannot wait for the automatic synchronization (for example, if your
application is about to exit), or if you want to update user defaults
to what is on disk even though you have not made any changes.
</from the NSUserDefaults docs:>
Am I wrong in assuming that changes made to internetDefaults (the
dictionary returned by the persistentDomainForName: method) are
automatically are copied to file?
--
Chris Parker <email@hidden>
Cocoa Frameworks Engineer