-1

我收到错误消息:expected ':'大概是因为initWithTitle:@"You downloaded %i boards", iboard下面的短语。你能帮我修一下吗?

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You downloaded %i boards", iboard message:@"Press Ok to continue" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
4

2 回答 2

2

代替

initWithTitle:@"You downloaded %i boards", iboard 

initWithTitle:[NSString stringWithFormat:@"You downloaded %i boards", iboard]
于 2013-03-03T16:02:54.833 回答
2

你把你的代码弄得一团糟。

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You downloaded %i boards", iboard message:@"Press Ok to continue" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];

它应该是 :

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"You downloaded %i boards", iboard]
                                                message:@"Press Ok to continue" 
                                               delegate:self 
                                      cancelButtonTitle:@"Ok" 
                                      otherButtonTitles:nil];
于 2013-03-03T16:04:13.923 回答