2011-11-03 102 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"); 
    } 
}