I have a variable declared in the header file :
@interface
int _nPerfectSlides;
and
@property (nonatomic, readwri
I know this is old, but it still comes up. Try making it a static. Here's I'm altering the code a bit to make it increment.
// Hit.h
#import
@interface Hit : NSObject
+ (void)hit;
@end
// Hit.m
#import "Hit.h"
@implementation Hit
static int val = 0;
+ (void)hit {
val += 1;
[self showHit];
}
+ (void)showHit {
NSLog(@"hit value: %d", val);
}
@end
//main.m
#import
#import "Hit.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
[Hit hit];
[Hit hit];
[Hit hit];
}
return 0;
}