Re: Inter-class Dependent Keys
Re: Inter-class Dependent Keys
- Subject: Re: Inter-class Dependent Keys
- From: Jim Correia <email@hidden>
- Date: Fri, 11 Mar 2005 12:52:07 -0500
On Mar 5, 2005, at 7:18 AM, Jonathon Mah wrote:
What is the correct way to handle this situation? I have a few
thoughts, but they all involve more code than I feel should be
necessary.
I think the correct solution is to rewrite your button title accessor
so it doesn't generate the value dynamically, but returns a stored
value which you update when canSelectNext changes.
Jim
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
if ((object == arrayController) && [keyPath
isEqualToString:@"canSelectNext"])
{
if ([arrayController canSelectNext])
{
[self setButtonTitle: @"Next"];
}
else
{
[self setButtonTitle: @"Add"];
}
}
}
- (NSString *)buttonTitle
{
return buttonTitle;
}
- (void)setButtonTitle:(NSString *)title
{
if (buttonTitle != title)
{
[buttonTitle release];
buttonTitle = [title copy];
}
}
_______________________________________________
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