Re: object type testing
Re: object type testing
- Subject: Re: object type testing
- From: Andy Lee <email@hidden>
- Date: Wed, 10 May 2006 13:29:01 -0400
On May 10, 2006, at 12:54 PM, Keith Ray wrote:
Is there a way to test if a class is a subclass of NSObject (or test
that it implements a certain protocol) that will not crash if the
object is not a subclass of NSObject?
Others would know better than I, but I would try looking at the low-
level internals of the objc_class data structure:
<file://localhost/Developer/ADC Reference Library/documentation/
Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html>
objc_class
Defines an Objective-C class.
struct objc_class
{
struct objc_class* isa;
struct objc_class* super_class;
const char* name;
long version;
long info;
long instance_size;
struct objc_ivar_list* ivars;
struct objc_method_list** methodLists;
struct objc_cache* cache;
struct objc_protocol_list* protocols;
};
[...]
protocols
A pointer to a objc_protocol_list data structure. This is a
list of the formal protocols this class claims to implement.
--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