[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Categories, NSString and +load
From: |
Andreas Kostler |
Subject: |
Categories, NSString and +load |
Date: |
Fri, 8 Oct 2010 17:21:05 +1000 |
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];
}
- Categories, NSString and +load,
Andreas Kostler <=