I am wondering why in the following code the static integer does not stay 0? Is it because in objective-c classes are objects, too and the CoolClass Class is kind of kept around like a singleton?
@interface CoolClasss : NSObject
+(void)staticMethod;
@end
@implementation CoolClass
static int integer=0;
+(void)staticMethod {
NSLog(@"integer: %d", integer);
integer++;
}
@end
int main (int argc, const char * argv[]) {
for (int i=0; i<10; i++) {
[CoolClass staticMethod];
}
return 0;
}
Thank you,
Charles