Re: Does +isSubclassOfClass work?
Re: Does +isSubclassOfClass work?
- Subject: Re: Does +isSubclassOfClass work?
- From: James Spencer <email@hidden>
- Date: Thu, 1 Jan 2004 10:52:03 -0600
On Jan 1, 2004, at 9:04 AM, Thomas Lachand-Robert wrote:
Is there something that I don't understand with NSObject
+isSubclassOfClass: ?
If you fire a simple foundation tool with only this content:
int main () {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Class s = [NSObject class];
Class c = [pool class];
if ([s isSubclassOfClass:c]) return 1;
You've got this backwards. isSubclassOfClass asks if the receive (s in
this case, an NSObject) is a subclass of the parameter (c in this case,
an NSAutoreleasePool). This is obviously not the case here; NSObject
is NOT a subclass of an NSAutoreleasePool so it doesn't return.
NSCAssert ([c superclass] != s, @"error!") ;
You've got this backwards too. Assertions call the assertion handler
if the condition tests false. Here, c's superclass is an NSObject so
your condtion becomes "s != s". This is obviously false and the
assertion handler gets called.
return 0;
}
James P. Spencer
Rochester, MN
email@hidden
"Badges?? We don't need no stinkin badges!"
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.