With the following code I am trying to fire an action to add +1 to an integer in a UILabel. When the action is fired the number adds +1 fine. The problem I'm facing, is telling the label which number is displayed. From my console I am getting "2" every time I fire the action, even when the value of the label is "4" (in which case I'd like the console to read "1"). Any idea what I've done wrong?
Code:
- (IBAction) xplus1{
Count1 = Count1 + .5;
NSString *numValue = [[NSString alloc] initWithFormat:@"%d", Count1++];
NSLog(numValue);
if (l1.text == @"4")
{ NSLog(@"1");
l1.text = @"A";
[numValue release];
}else {
NSLog(@"2");
l1.text = @"B";
[numValue release];
}
}