-3

在 [currentValue, targetValue, difference] 方面需要帮助;线。它说初始化元素不是编译时元素。请发布解决方案。

NSString *message = [NSString stringWithFormat:
                         @"The value of the slider is: %d\nThe target value is: %d\nThe difference is: %d",
                         [currentValue, targetValue, difference];
UIAlertView *alertView = [[UIAlertView alloc]]
                              initWithTitle:@"Hello, World!"
                              message:message
                              delegate:nil
                              cancelButtonTitle:@"OK"
                              otherButtonTitles:nil];
4

1 回答 1

4

应该:

NSString *message = [NSString stringWithFormat: @"The value of the slider is: %d\nThe target value is: %d\nThedifference is: %d", currentValue, targetValue, difference];

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Hello, World!"
                                                    message:message
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];

在当前和 UIAlertView 分配之后,您有一个额外的 '[' 和额外的 ']'。

于 2013-05-10T02:45:37.443 回答