У меня есть uilabel, и он не отображает правильный текст, потому что это ноль.Как я могу остановить ярлык от нуля?Спасибо МКДев
- (IBAction)tapped
{
if ([[NSUserDefaults standardUserDefaults] boolForKey:kTimerOn] == NO) {
originalCountdownTime = 10;
countdownTime = originalCountdownTime;
[timeLeft setText:[NSString stringWithFormat:@"%d", countdownTime]];
countdownTimer = [[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countDownOneSecond) userInfo:nil repeats:YES] retain];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kTimerOn];
}
[self setTapAmount:tapAmount];
}
- (void)setTapAmount:(UILabel *)label
{
++numberOfTaps;
NSString *countString = [NSString stringWithFormat:@"%d", numberOfTaps];
[label setText:countString];
NSLog(@"%@", countString);
}
- (void)countDownOneSecond
{
int newTime = --countdownTime;
timeLeft.text = [NSString stringWithFormat:@"%d", newTime];
if (countdownTime == 0)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Congratulations" message:[NSString stringWithFormat:@"You Tapped %i times in %i seconds!", numberOfTaps, originalCountdownTime] delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"Try Again", @"View Local Leaderboard",nil];
[alert show];
[alert release];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:kTimerOn];
[countdownTimer invalidate];
}
}