I’m trying to add the value 1 to an int each time I press a button, but when I do it adds 4.
-(IBAction)donePressed {
timesPressed ++;
thirdLabel.text = [NSString stringWithFormat:@"Times done: %i", timesPressed];
}
When I do this, it prints out 4,8,12,16 instead of 1,2,3,4
Thanks
According to your last comment above, timesPressed is defined as
int *timesPressed;This is incorrect, you want to define it as
int timesPressed;Doing
+on a pointer type multiplies the addition by the size of the type, read up on pointers and pointer arithmetic if you want to know more.