I have this simple number counter app "+" to add one, "-" to subtract one.
My problem is when I press the "+" button the number will subtract by one, then if i press it again it will begin to work like it's supposed to.
Here is my code:
Code:
int count = 0;
-(void)awakeFromNib {
current_number.text = @"0";
}
- (IBAction)add1 {
if(count >= 99) return;
NSString *numValue = [[NSString alloc] initWithFormat:@"%d", count++];
current_number.text = numValue;
[numValue release];
}
- (IBAction)subtract1 {
if(count <= -99) return;
NSString *numValue = [[NSString alloc] initWithFormat:@"%d", count--];
current_number.text = numValue;
[numValue release];
}
What's the problem?