Re: + initialize docs conflict?
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