Re: accessor question
Re: accessor question
- Subject: Re: accessor question
- From: sinclair44 <email@hidden>
- Date: Thu, 27 Feb 2003 15:43:05 -0500
On 2/27/03 3:15 PM, "Koen van der Drift" <email@hidden> wrote:
>
Hi,
>
>
Just curious, is it considered good programming practice to add some
>
code to an accessor that tells an object to update itself, for
>
instance:
>
>
-(void)setMyValue:(float)aValue
>
{
>
myValue = aValue
>
>
[self recalculate];
>
}
It would be faster to do it like this, if you can (how much faster depends
on what -recalculate does):
- (void)setMyValue:(float)aValue
{
myValue = aValue;
needsRecalc = YES;
}
- (float)myValue
{
if (needsRecalc)
[self recalculate];
return myValue;
}
--
-- sinclair44
[self becomeWorldDictator];
- (void)becomeWorldDictator
{
[[world currentLeaders] assassinate];
[[world citizens] terrorize];
[world setCurrentLeaders:[NSArray arrayWithObject:self]];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.