Tuesday, April 24, 2012

On iOS, why the init in ViewController didn't work?

In the ViewController's interface, I have



@property int count;


and in the implementation, I have



@synthesize count;

-(id) init {
self = [super init];
if (self) {
self.count = 100;
}
return self;
}

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"%i", self.count++);
}


but for some reason, the first time self.count got printed, it is 0 but not 100?





No comments:

Post a Comment