objective-c - UIAlertView dismissWithClickedButton

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

}

我有一个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];

错误是在(() token 之前的预期')'

我不明白,NSLogs可以帮助记住哪个选项。
提前致谢

最佳答案

您错过了结尾括号:

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

关于objective-c - UIAlertView dismissWithClickedButtonIndex :animated: method error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8001833/

相关文章:

asp.net - 加载共享类库时出错

compiler-errors - nant 构建文件使用 nant 0.86 而不是 0.91 a

java - 编译Java项目时出错

iphone - 编译我的应用程序没有错误,但是在设备上编译时挂起

objective-c - 尽管导入了正确的 header ,但使用自定义类的编译器错误

php - 使用PHP的exec()函数(或类似函数),如何显示终端错误输出?

java - 编译时出现一个或多个错误的NetBeans项目

java - Java编译时错误: reached end of file while parsin

android - 在 Android 中初始化一个大的常量数据结构

compiler-construction - lex 使用来自 lex.yy.c 文件的 flex