Re: use class objet instead of an instance object
Re: use class objet instead of an instance object
- Subject: Re: use class objet instead of an instance object
- From: Andy Lee <email@hidden>
- Date: Mon, 2 May 2005 20:40:16 -0400
On May 2, 2005, at 3:58 PM, Ivan S. Kourtev wrote:
NSArray* a = [NSArray arrayWithObject:[BadFoo class]];
Is there any way to implement this idea without having to retype
[BadFoo class] all the time?
I wouldn't bother trying to find an alternative, since the cost of the
extra typing is negligible, and the cost of the extra method call is
almost certainly negligible. Since Cocoa programmers are familiar with
the "[BadFoo class]" construct, any replacement you use would decrease
readability.
But just for the sake of discussion... you could try declaring a global
variable BadFooClass and initializing it to [BadFoo class]:
extern id BadFooClass; // <-- in BadFoo.h
id BadFooClass = [BadFoo class]; // <-- at the bottom of BadFoo.m
But you would have to do this for every class you want to use in this
way. It doesn't really make sense to bother.
--Andy
_______________________________________________
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