Array Bindings and NSUserDefaultsController / endEditing
Array Bindings and NSUserDefaultsController / endEditing
- Subject: Array Bindings and NSUserDefaultsController / endEditing
- From: Bjoern Kriews <email@hidden>
- Date: Wed, 25 Feb 2004 00:44:13 +0100
What about binding an NSArrayControllers content directly to values.xy
of an NSUserDefaultsController ?
When I started playing with bindings I wanted to keep some preferences
edited in a TableView this way -
using an NSArrayController with NSMutableDictionaries seemed natural to
the concept.
It didn't work. The dictionaries become immutable.
Later I found out that this stops happening when I
-[NSUserDefaultsController setAppliesImmediately: NO].
Still, I can add new rows and they get saved but the
UserDefaultsController does not save
changes I make in existing rows (changes are persistent thoughout the
application, just
not saved to the real NSUserDefaults).
Is there a way to register dependent keys as "values.xy" depends on
"values.xy.blah" ?
I suppose not, otherwise they would be called dependent keyPathes,
right ?
On another note, when I open my Preferences-Window, edit a textfield
(bound to SharedUserDefaultsC.)
in there and then move to the mainwindow the value is not taken
(because no end-editing did take place)
and - more importantly - not saved.
I made up a very ugly solution to this:
- (void) cleanup
{
NSUserDefaultsController *udc = [NSUserDefaultsController
sharedUserDefaultsController];
// force udc to notice that the user has "left" if he was editing a
field
[udc commitEditing];
// otherwise we don't have them after a user quits directly after
entry - sigh
[udc save: self];
}
- (void) windowDidResignKey:(NSNotification *)aNotification
{
[self cleanup];
}
- (void) windowWillClose:(NSNotification *)aNotification
{
[self cleanup];
}
Is there a better solution ?
Thanks, Bjoern
_______________________________________________
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.