UIAlertView dismissWithClickedButtonIndex: animated: ошибка метода - PullRequest
0 голосов
/ 04 ноября 2011
  - (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];

Ожидается ошибка ')' before '(' token

Я не понимаю, NSLogs должны были помочь вспомнить, какой вариант был каким. Заранее спасибо

1 Ответ

0 голосов
/ 06 января 2012

Вы пропустили заключительную скобку:

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