Re: Properties and bindings
Re: Properties and bindings
- Subject: Re: Properties and bindings
- From: Nick Zitzmann <email@hidden>
- Date: Mon, 22 Sep 2008 20:42:51 -0600
On Sep 22, 2008, at 7:35 PM, D.K. Johnston wrote:
I'm trying to learn how to use bindings. MyObject has an NSInteger
myInt. I used @property and @synthesize to make myInt into a
property. In IB I bound an NSTextField to the myInt property. Now
when I do this:
self.myInt = 123;
when initialising MyObject, the value shows up in the text field.
But if I do this instead:
myInt = 123;
the textfield just shows '0'. What's happening here?
The self.myInt runs through the accessor method that was synthesized
by the runtime, and a KVO notification was sent out. Setting myInt
directly circumvented the accessor, so no KVO notification was sent,
since the change occurred behind the back of the runtime. Without that
KVO notification, the text field doesn't know myInt changed.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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