Re: Bindings & ivars
Re: Bindings & ivars
- Subject: Re: Bindings & ivars
- From: Joanna Carter <email@hidden>
- Date: Mon, 5 Apr 2010 21:41:00 +0100
Le 5 avr. 2010 à 19:53, Charles Burnstagger a écrit :
> Why, after I have connected a control in my nib. window using bindings can I no longer access it from code?
>
> After connecting a checkbox control using bindings, when my window controller loads, that control's ivar shows up as nil.
A binding is a mechanism whereby a property of something like a control can be linked to a property of another object. It allows the "observing" object to be updated when the value of the "observed" property changes. It is not meant to be a means of talking to an object in a NIB.
If you need access to an object in the N IB, then you need to add an IBOutlet to the controller class and hook it up to the appropriate object in the NIB.
If you want to use the "observer" mechanism of bindings, then you cannot use an ivar in the observed class, you need a KVO compliant property instead, otherwise the notifications of change will not get sent to the observing object.
Joanna
--
Joanna Carter
Carter Consulting
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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