OK, so I'm replying to my own post here :), for the benefit of the
archives I guess.
But I have a new question based on my new findings, but I'll start a new
thread.
Sean McBride (<cwatson...>) on Tue, Aug 3, 2004 01:00 said:
> I'm trying to understand exactly when NSUserDefaultsDidChangeNotification
> is posted. Or, more generally, when using NSUserDefaultsController, when
> and how can I act on the changed preferences?
>
> mmalc's "ControlledPreferences" example has been very useful, but I
> notice what I consider a strange behaviour:
>
> - if I change the textfield, NSUserDefaultsDidChangeNotification is
> posted once
> - the 1st time I click the colourwell (without changing colours), its
> posted 4 times
> - subsequent times, its not posted at all unless i change colours
> - same thing with the 'fonts' button
> - clicking the 'factory' button also gets me 4 postings
>
> 4 is the number of keys this app has in its defaults database.
What I did not realise is that the NSUserDefaultsDidChangeNotification
has changes for bazillions of defaults, not just those related to my app.
I printed out all the defaults (using [[note object]
dictionaryRepresentation]) and did a text diff and now understand why I
see so many notifications: they are not from changes to my defaults at
all, but the OS's:
193 : <CFString 0x383fa0 [0x2b9a30e0]>{contents = "NSWindow Frame
NSColorPanel"} = <CFString 0x383fd0 [0x2b9a30e0]>{contents =
"325 263 201 309 0 0 1024 746 "}
143 : <CFString 0xa2dcc530 [0x2b9a30e0]>{contents = "NSColorPanelMode"}
= <CFString 0x3ca750 [0x2b9a30e0]>{contents = "6"}
I guess its remembering where the colour panel goes, etc.
_______________________________________________
cocoa-dev mailing list | <cocoa-dev...>
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.