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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to