• 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: + initialize docs conflict?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: + initialize docs conflict?


  • Subject: Re: + initialize docs conflict?
  • From: Ricky Sharp <email@hidden>
  • Date: Wed, 02 Feb 2005 09:35:30 -0600

On Wednesday, February 02, 2005, at 09:13AM, Shaun Wexler <email@hidden> wrote:

>On Feb 1, 2005, at 11:43 AM, Ricky Sharp wrote:
>
>> I've seen (and have been using) this pattern in NSControl subclasses
>> that need to set their associate cell.  For example,
>>
>> + (void)initialize
>> {
>> 	if (self == [IIButton class])
>> 		{
>> 		[self setCellClass:[IIButtonCell class]];
>> 		}
>> }
>
>This may belong on the perfoptimization-dev list, but I just wanted to
>point out some optimizations that should become normal practice.  If
>you need to use a variable retrieved by a message more than once in a
>method, you should cache it locally:
>
>+ (void)initialize
>{
>	Class class = [IIButton class];
>
>	if (self == class) {
>		[self setCellClass:class];
>		... // use class elsewhere
>	}
>}

This doesn't apply at all.  In the original code above, there are two different receivers of the class message.  One is the NSControl subclass; the other the NSCell subclass.

--
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

References: 
 >Re: + initialize docs conflict? (From: "Buck, Erik (Space Technology)" <email@hidden>)
 >Re: + initialize docs conflict? (From: mmalcolm crawford <email@hidden>)
 >Re: + initialize docs conflict? (From: Ricky Sharp <email@hidden>)
 >Re: + initialize docs conflict? (From: Shaun Wexler <email@hidden>)

  • Prev by Date: Re: + initialize docs conflict?
  • Next by Date: Re: + initialize docs conflict?
  • Previous by thread: Re: + initialize docs conflict?
  • Next by thread: Re: + initialize docs conflict?
  • Index(es):
    • Date
    • Thread