Mailing Lists: Apple Mailing Lists

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

use class objet instead of an instance object



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

This email sent to 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.