我有一個tap計數器,這是「Who Wins」代碼。每當Flipped(int timer)等於30時,該應用程序都會崩潰,並且它正在決定誰的抽頭數最多。它總是說「玩家2贏」並凍結。請幫忙。 Number是一個攻絲者的數值,Number1是第二個攻絲者的數值。我該如何解決?Objective-C代碼掛起
- (void)countup
{
if (Fliped == 30)
{
//error message
if (Number < Number1)
{
myAlertView = [[UIAlertView alloc] initWithTitle:@"Stop!" message:@"Player 2 Wins!" delegate:self
cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
timer = [NSTimer scheduledTimerWithTimeInterval:0.0
target:self selector:@selector(countup)userInfo:nil repeats:YES];
[myAlertView show];
}
if (Number > Number1)
{
myAlertView = [[UIAlertView alloc] initWithTitle:@"Stop!" message:@"Player 1 Wins!" delegate:self
cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
timer = [NSTimer scheduledTimerWithTimeInterval:0.0
target:self selector:@selector(countup)userInfo:nil repeats:YES];
[myAlertView show];
}
else
{
MainInt += 1;
seconds.text = [NSString stringWithFormat:@"%d", MainInt];
Fliped += 1;
secondsFlip.text = [NSString stringWithFormat:@"%d", Fliped];
}
}
在此先感謝。
什麼可能是這次崩潰的原因?
不客氣! (你有問題嗎?) –
我不知道,但你可能需要@selector(計數進位)和USERINFO – rubixibuc
之間的空間這有沒有關係Xcode和我已經刪除從標題自己的標籤和文字如果在我可以保存自己的編輯之前它沒有被編輯幾次;-) –