Re: Binding name must be same as ivar name?
Re: Binding name must be same as ivar name?
- Subject: Re: Binding name must be same as ivar name?
- From: Ricky Sharp <email@hidden>
- Date: Thu, 24 Feb 2005 12:03:10 -0600
On Thursday, February 24, 2005, at 11:39AM, glenn andreas <email@hidden> wrote:
>The real power of "binding names need not correspond" isn't just "use a
>different name" but that you can have derived information bound and
>automatically updated when the data it is derived from changes.
>
>For example, if there are two integer ivars 'p' and 'q', you can have a
>binding corresponding to {p,q} being a valid hyperbolic tessellation:
>
>- (BOOL) isValidHyperbolicTessellation
>{
> return (p - 2) * (q - 2) > 4;
>}
>
>and if you have:
>
> [self setKeys: [NSArray arrayWithObjects: @"p", @"q", NULL]
>triggerChangeNotificationsForDependantKey:
>@"isValidHyperbolicTessellation"];
>
>in your classes +initialize method, and bind a text field with an error
>message who's "hidden" property is bound to
>"isValidHyperbolicTesselation" then setting p or q will automagically
>update everything to cause the message to be hidden or not (or you
>could have it return an error message as an NSString and bind to
>that).
Thanks for this followup, Glenn. This is definitely very powerful and I can see the use of it for some of my more complex palette items.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
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