bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objc_next_class


From: Nicola Pero
Subject: Re: objc_next_class
Date: Fri, 14 Jun 2002 02:40:50 +0100 (BST)

Definitely the NSLog call is causing problems - try adding a 'NSLog' call
before this code snippet (looks like the first call to NSLog is
initializing something which is confusing objc_next_class() ... bug in the
runtime ?) ... I'd like to check if the new 3.1 runtime still has this
problem (since I rewrote all that runtime code).

Anyway - after adding a dumb NSLog call before the code, I get all the
classes, except one of the last ones gives -

error: Object (class)
Object does not recognize respondsToSelector:
Aborted

not much you can do about it ... 

NSLog (@"%@", [Object class]);

seems to be causing an error.

Replacing the NSLog with

NSLog (@"fail on %@\n", NSStringFromClass (cl));

fixes this problem.


Hope all that helps :-)

Please post questions/bug reports etc to a mailing list, such as
bug-gnustep@gnu.org, so that other people get the opportunity of taking
part/commenting/reading.


On Tue, 11 Jun 2002, Marko Riedel wrote:

> 
> Hi all,
> 
> I am working on another example. I don't want to go into the details
> until I have a working program.
> 
> I have a question about objc_next_class. It used to work fine, but now
> it no longer iterates over all classes. Here is the code that I am
> using:
> 
>     void *state = NULL;
>     Class cl;
>     id primitive;
> 
>     while((cl = objc_next_class(&state)) != nil){
>         if([NSStringFromClass(cl) hasPrefix:PRIM_CLASS_PREF]){
>             primitive = [[cl alloc] init];
>             NSLog(@"primitive %@ %@\n", cl, primitive);
>             [prim setObject:primitive 
>                   forKey:[primitive primName]];
>         }
>         else{
>             NSLog(@"fail on %@\n", cl);
>         }
>     }
>     NSLog(@"last %@\n", cl);
> 
> The output is as follows:
> 
> Jun 11 17:57:40 ...[9998] fail on NSPrinter
> Jun 11 17:57:40 ...[9998] last (nil)
> 
> Where are all the other classes that I know are there, like NSObject,
> NSString, NSDictionary etc.?
> 
> What is going on here? I also tried class_table_next, but it doesn't
> seem to be available in the distribution that I downloaded.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]