• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Inter-class Dependent Keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Inter-class Dependent Keys (From: Jonathon Mah <email@hidden>)

  • Prev by Date: Re: Cocoa from C++ (dont want to mix it)
  • Next by Date: Rotating an image in an NSImageView subclass
  • Previous by thread: Re: Inter-class Dependent Keys
  • Next by thread: -[NSSet initWithSet:copyItems:] crashing
  • Index(es):
    • Date
    • Thread