discuss-gnustep
[Top][All Lists]
Advanced

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

RE: Categories, NSString and +load


From: Nicola Pero
Subject: RE: Categories, NSString and +load
Date: Fri, 8 Oct 2010 10:09:14 +0200 (CEST)

It sounds like a bug in the GNU Objective-C Runtime, most likely this one --

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16110

It's on my list for GCC 4.6.0.

But please note that (in practice) most likely you want to use +load 
as little as possible.  Almost anything else works more reliably. ;-)

Thanks

-----Original Message-----
From: "Andreas Kostler" <andreas.koestler.leica@gmail.com>
Sent: Friday, 8 October, 2010 09:21
To: discuss-gnustep@gnu.org
Subject: Categories, NSString and +load

Hello everyone,
Please help me on this one. The code snippet below output 
1
0

Hence, [NSObject load] gets called, [NSString load] doesn't. 
Can anyone explain this behaviour?
Kind Regards
 

#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
static int a = 0;
static int b = 0;

@implementation NSObject (objectCategory)
+(void)load {
 a  = 1;
}
@end

@implementation NSString (stringCategory)
+ (void)load {
 b = 1;
}
@end

int main() {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        NSLog (@"%d", a);
        NSLog (@"%d", b);
        [pool release];
}

_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnustep





reply via email to

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