Re: IB crash with custom binding
Re: IB crash with custom binding
- Subject: Re: IB crash with custom binding
- From: Ricky Sharp <email@hidden>
- Date: Wed, 23 Feb 2005 15:46:46 -0600
On Feb 23, 2005, at 3:23 PM, mmalcolm crawford wrote:
On Feb 23, 2005, at 12:40 PM, Ricky Sharp wrote:
-
(void)setObservedObjectForBaseColor:(id)newObservedObjectForBaseColor
{
observedKeyPathForBaseColor = newObservedObjectForBaseColor;
}
Views should retain the objects they're observing.
That was a bug in my original code. I fixed it a while back -- do you
have the latest version (which also now calls
[self stopObservingGraphics:[graphicsContainer
valueForKeyPath:graphicsKeyPath]];
in unbind: -- thanks to Sean for spotting the omission)?
That makes sense, thanks.
In terms of the code that I have, I used two different sources as a
reference: your JoystickPalette code (you sent that attachment out to
the list on the 27-Jan-2005) and what is included in your
GraphicsBindings sample.
Comparing JoystickView.m in both code sets to what's on the web page
[1], it appears that all three have the bug. Inside of bind: (which is
shown in Listing 2 on the web page), this is done:
observedObjectForAngle = observableObject;
observedKeyPathForAngle = [keyPath copy];
I do see your call to stopObservingGraphics, but that's only done
inside your GraphicsView.m module for the array of Graphics objects (a
to-many situation).
But in GraphicsView.m, it is using correctly coded accessors for both
observedObjectXXX and observedKeyPathXXX. The former performs a retain
and the latter performs a copy.
Thank you very much for pointing this out and thanks also to Sean for
hinting towards using retain.
Shall I file a bug against the web site [1]?
[1]
<http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Concepts/HowDoBindingsWork.html>
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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