• 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: use class objet instead of an instance object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


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

  • Prev by Date: Re: OutlineEdit example (outlineView:heightOfRowByItem:)
  • Next by Date: Re: When is (NSColor) black not black?
  • Previous by thread: use class objet instead of an instance object
  • Next by thread: Using NSPropertyListSerialization with NSArray of NSDictionaries
  • Index(es):
    • Date
    • Thread