Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use class objet instead of an instance object



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >use class objet instead of an instance object (From: "Ivan S. Kourtev" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.