Re: Getting a list of all classes, etc...
Re: Getting a list of all classes, etc...
- Subject: Re: Getting a list of all classes, etc...
- From: Graham Cox <email@hidden>
- Date: Thu, 27 Mar 2008 20:50:36 +1100
Actually I did try it this way at one point, and it worked OK with one
small kink. It caused the +initialize method of the classes being
tested to get called, which for some classes (bearing in mind that
it's going through a list of EVERY class in the runtime), triggered
some warnings about deprecated classes, for example from
NSATSGlyphRenderer (I think it was). The advantage of this way is that
it doesn't invoke any methods on the class being tested itself, so
works very stealthily ;-)
------
S.O.S.
On 27 Mar 2008, at 5:59 pm, Chris Suter wrote:
On 27/03/2008, at 4:59 PM, Graham Cox wrote:
This worked well (after a little tweaking!) thanks - got the whole
caboodle running now. I note that NSObject's superclass is NULL, so
I had to switch the order of the while() test in order to correctly
detect plain NSObjects (admittedly this will probably never be
needed in practice).
Here's my implementation (including objective C 2.0 variant), for
anyone's further use:
[snip]
You could probably implement classIsSubclassOfClass as:
BOOL classIsSubclassOfClass (const Class aClass, const Class subclass)
{
return class_getClassMethod (aClass, @selector (isSubclassOfClass:))
? [aClass isSubclassOfClass:subclass] : NO;
}
- Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden