• 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
isKindOfClass vs. loading bundles: nope?!?!?!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: isKindOfClass vs. loading bundles: nope?!?!?!?
      • From: Rosyna <email@hidden>
    • Re: isKindOfClass vs. loading bundles: nope?!?!?!?
      • From: Chris Kane <email@hidden>
    • Re: isKindOfClass vs. loading bundles: nope?!?!?!?
      • From: Andy Lee <email@hidden>
    • Re: isKindOfClass vs. loading bundles: nope?!?!?!?
      • From: Andy Lee <email@hidden>
    • Spreadsheet Widget
      • From: Bob Newhart <email@hidden>
  • Prev by Date: Filename
  • Next by Date: Re: drag-and-drop support in an NSTableView
  • Previous by thread: Re: Filename
  • Next by thread: Spreadsheet Widget
  • Index(es):
    • Date
    • Thread