isKindOfClass vs. loading bundles: nope?!?!?!?
isKindOfClass vs. loading bundles: nope?!?!?!?
- Subject: isKindOfClass vs. loading bundles: nope?!?!?!?
- From: Ondra Cada <email@hidden>
- Date: Thu, 21 Mar 2002 05:10:00 +0100
Hello,
am I stupid or is it the new Foundation? Anyway, what about the following
code?
@interface NSObject (WhatTheHeck) @end
@implementation NSObject (WhatTheHeck)
+(BOOL)ocs_isKindOfClass:(Class)class {
Class myself=self;
while (myself!=[NSObject class]) {
if (myself==class) return YES;
myself=[myself superclass]; // at least THIS works!
}
return NO;
}
@end
@implementation Controller
-(void)loadedBundleClasses:(NSNotification*)nn {
NSEnumerator *en=[[[nn userInfo] objectForKey:NSLoadedClasses]
objectEnumerator];
NSString *s;
while (s=[en nextObject]) {
Class class=NSClassFromString(s);
if ([class ocs_isKindOfClass:[MLLoadableObject class]])
NSLog(@"got a class %@ (%d)",s,[class
isKindOfClass:[MLLoadableObject class]]);
}
}
...
NSNotificationCenter *centre=[NSNotificationCenter defaultCenter];
[centre addObserver:self selector:@selector(loadedBundleClasses:) name:
NSBundleDidLoadNotification object:nil];
...
The printout is
2002-03-21 04:58:56.733 MLIndexing[9669] got a class MLCDocReader (0)
that (I mean the zero in the parentheses) should be nonsense, no? Or do I
overlook something?
(BTW, of course I originally used isKindOfClass: in the if, and for a
considerable time tried to find why the dickens those classes are not
loaded! Sigh...)
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
2K Development: email@hidden
http://www.2kdevelopment.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.