• 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: object type testing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: object type testing (From: Erik Buck <email@hidden>)
 >Re: object type testing (From: "Keith Ray" <email@hidden>)

  • Prev by Date: Boolean Searches with Core Data
  • Next by Date: Re: Reordering a table view with Core Data
  • Previous by thread: Re: object type testing
  • Next by thread: DXT1/3/5 image format - where to get a NSImageRep
  • Index(es):
    • Date
    • Thread