Graphics Binding & keys on a deeper level
Graphics Binding & keys on a deeper level
- Subject: Graphics Binding & keys on a deeper level
- From: Kaspar Fischer <email@hidden>
- Date: Thu, 1 Dec 2005 10:36:20 +0100
Hi all,
I have a conceptual question on how to write
a view with bindings. I could solve the problem
in the end, but do not know whether my solution
is overkill -- I fear I misunderstand bindings
and do it in a much too complicated way.
I used mmalc's Graphics Binding sample code,
http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
to build a view that visualizes the objects
in an array. This works fine, but I am running
into problems because the objects of the array
themselves contain arrays again. That is,
the outer array contains objects like this
obj1 with array {subobj1}
obj2 with array {subobj1',subobj2'}
obj3 with array {}
...
The problem pops up when the outer array changes,
for instance, when obj2 gets removed by CoreData's
Undo machinery. What happens in my case is that
CoreData first removes subobj1' and subobj2' and
only then removes obj2. So when my view observes
the removal of obj2, obj2 does not have any
subobjects anymore -- and when my code steps
through the (empty) list of subobjects to dere-
gister itself as an observer from these subobjects,
it does nothing at all (because the list is empty)!
In this way, changes of subobj1' and subobj2' are
still observed, even when my view is deallocated,
which of course results in a crash.
I fixed this by also observing the subarrays.
I now get notified when subobj1' and subobj2'
are removed, and I deregister the view as an
observer at this moment.
My question is: is this the way it is supposed to be
done? This gets quite complicated if the subobjects
themselves *also* have arrays whose contents my
view wants to display...
Could anybody clarify on this?
Thanks in advance,
Kaspar
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden