Wdrażanie licznika czasu w Objective-c?
Jestem nowy w programowaniu na iOS. Pracuję nad dopasowywaniem słów. W tej grze muszę zaimplementować licznik czasu, który pokazuje minuty i sekundy. Chcę, kiedy moja gra zostanie uruchomiona, mój timer rozpocznie się od 3 minut. Teraz chcę zmniejszyć ten zegar w odwrotnym kierunku za pomocą sekund. mój kod działa po prostu przez sekundy… jest mój kod:
secondsLeft--;
int seconds = (secondsLeft %3600) % 60;
Timerlbl.text = [NSString stringWithFormat:@"%02d",seconds];
if (seconds==0)
{
UIAlertView *pAlert = [[UIAlertView alloc]initWithTitle:@"Sorry!!"
message:@"TimeOver" delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:@"Cancel",nil];
[pAlert show];
[pAlert release];
}
}
W Viewdidload dzwonię przez timer ..
countDown=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self
selector:@selector(TimeOver) userInfo:nil repeats:YES];
błagania, które ktoś mnie prowadzi, jak mogę to zrobić w minutach i sekundach.