[Pyobjc-dev] Key Value Observing of lists?
Brought to you by:
ronaldoussoren
|
From: Orestis M. <or...@or...> - 2008-05-18 19:15:24
|
Hi,
I'm trying to bound an NSTableView to a list using an array
controller. This works fine, as long as I don't mutate the list
(list.append, for example).
I have a workaround where I surround changes to the list with:
self.willChangeValueForKey_("selections")
self.selections.append("new selection")
self.didChangeValueForKey_("selections")
This works fine for now, but gives me the following messages in the
Console:
*** Ignoring *** addObserver:forKeyPath:options:context: for
'partName' (of <NSTableBinder: 0x3fad90>{object: <NSTableView:
0x3eabc0>, bindings: content=arrangedObjects} with 0 in 0x0).
(where partName is an attribute in the object that gets stored in the
list).
I presume that when I issue the above notifications, the KVO mechanism
walks the list and tries to observe every object again, but they're
already observer and thus ignored. Am I missing something obvious or I
must write my own wrapper around list? I've found the accessor
decorator in the objc source, but I'm not sure about how should I use
for lists.
Regards,
--
Orestis Markou
or...@or...
http://orestis.gr/
|