2011-11-03 52 views
0
- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated{ 
if (0 == [alerts cancelButtonIndex]) { 
    NSLog(@"YES"); 
} else if (1 == [alerts cancelButtonIndex]) { 
    NSLog(@"NO"); 
} 

}UIAlertView中dismissWithClickedButtonIndex:動畫:方法錯誤

我有一個UIAlertView中,這裏是警報的初始化:

alerts = [[UIAlertView alloc] initWithTitle:@"Trumpets" message:@"Are you sure you would like to use one trumpet, this will give you 10 random units" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; 
    [alerts show]; 

錯誤之前預計 ')' '(' 令牌

我不明白,NSLogs幫助記住哪個選項是哪個。 在此先感謝

+0

在你上面的代碼我沒有看到的解僱方法的右括號「}」。這是正確的,或者你只是沒有把它全部粘貼。 – jamihash

回答

0

你錯過了結尾括號:

- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated{ 
    if ([alerts cancelButtonIndex] == 0) { 
     NSLog(@"YES"); 
    } else if ([alerts cancelButtonIndex] == 1) { 
     NSLog(@"NO"); 
    } 
}