gpt4 book ai didi

objective-c - UIAlertView dismissWithClickedButtonIndex :animated: method error

转载 作者:行者123 更新时间:2023-12-02 11:06:20 25 4
gpt4 key购买 nike

  - (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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com