• 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: accessor question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • RE: accessor question
      • From: "Jonathan E. Jackel" <email@hidden>
    • Re: accessor question
      • From: Dennis Munsie <email@hidden>
References: 
 >accessor question (From: Koen van der Drift <email@hidden>)

  • Prev by Date: accessor question
  • Next by Date: Finder & images
  • Previous by thread: accessor question
  • Next by thread: Re: accessor question
  • Index(es):
    • Date
    • Thread