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

use class objet instead of an instance object


  • Subject: use class objet instead of an instance object
  • From: "Ivan S. Kourtev" <email@hidden>
  • Date: Mon, 2 May 2005 15:58:09 -0400

Hi all,

I would like to use a class' object to indicate certain conditions (and be able to handle it like a regular object, put it in collections, etc.). I tried having something like that:

@interface Foo : NSObject { ... }
@end
@interface BadFoo : Foo {}
@end

and then using BadFoo instead of a Foo instance to indicate some error condition, for example. So I now know this cannot be done, because the BadFoo class object is not of type id and can only stand for the class object as the receiver in a message expression (p. 47 of the ObjC manual). For example, I cannot do

NSArray* a = [NSArray arrayWithObject:BadFoo];

but I can do

NSArray* a = [NSArray arrayWithObject:[BadFoo class]];

Is there any way to implement this idea without having to retype [BadFoo class] all the time? Or am I trying to do something stupid that doesn't make sense?

Thanks for any help!

--
ivan

_______________________________________________
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


  • Follow-Ups:
    • Re: use class objet instead of an instance object
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: Cocoa Technologies Back-Story?
  • Next by Date: Re: CoreData: Using willSave to update timestamps causes hang?
  • Previous by thread: Re: Overlay windows
  • Next by thread: Re: use class objet instead of an instance object
  • Index(es):
    • Date
    • Thread