Re: Bindings/NSUserDefaultsController issue
Re: Bindings/NSUserDefaultsController issue
- Subject: Re: Bindings/NSUserDefaultsController issue
- From: Loukas Kalenderidis <email@hidden>
- Date: Thu, 8 Mar 2007 15:46:49 +1100
Hi all,
I'm having another problem related to NSUserDefaultsController in
this other project now! I've got an NSArrayController's contentArray
bound to a key in an NSUserDefaultsController, and a prefs screen set
up with the interface elements bound to keys in this
NSArrayController - this all seems to work fine. The problem occurs
with using a custom class in the NSArrayController. I've set the
"Object Class Name" field for the NSArrayController in IB to
"Device" (my class), and set the value transformer on the
contentArray aspect to NSUnarchiveFromData. At this point I should
mention that "Device" is a subclass of NSMutableDictionary. The
objects seem to get stored in NSUserDefaults fine - I can see encoded
data when I `defaults read <domain>` from the command line, but my
subclass's initWithCoder: and encodeWithCoder: implementations are
never called. The objects appear to be NSMutableDictionarys when I
`po [device class]` (where "device" is a reference to one of these
objects - the same thing happens if I do something like `po
[[[devicesController arrangedObjects] objectAtIndex:0] class]`). So
it seems like the "Object Class Name" field is being ignored and the
array controller is creating NSMutableDictionarys.
Any ideas? Is there something I missed?
Thanks,
Loukas
On 05/03/2007, at 8:42 AM, Loukas Kalenderidis wrote:
Thanks for your suggestion, Keary. I've been pulled off this
project to work on something else for a little while, but when I
get back to the other project I'll try see what the behaviour is
with -synchronize.
Cheers,
Loukas
On 28/02/2007, at 6:39 AM, Keary Suska wrote:
on 2/26/07 7:04 PM, email@hidden purportedly said:
Now, even after calling the NSUserDefaultsController's save: method
(it's set to apply immediately, so this shouldn't matter), the
actual
defaults system doesn't reflect the change:
I may be brainfarting here but I believe that the defaults controller
actually never saves to disk. It's -save method only applies
changes to the
NSUserDefaults object, and not necessarily to disk.
IIRC, NSUserDefaults is periodically called with -synchronize,
which is used
to save defaults to disk.
However, no matter what, I believe -synchronize is called on
application
quit (as long as the app quits normally), so they should be
changed then, at
least.
So, you may not see changes immediately unless you call -synchronize.
However, if your previously set values seem to "revert" when you
do this,
there may be an issue with how you are defining the defaults set
in the
first place (e.g. non-persistent).
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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:
40rexbanner.com
This email sent to email@hidden
_______________________________________________
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:
40rexbanner.com
This email sent to email@hidden
_______________________________________________
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