2013-05-10 3 views
-3

Нужна помощь с [currentValue, targetValue, difference]; линия. В нем говорится, что элемент инициализации не является элементом времени компиляции. Пожалуйста, отправьте решение.Ошибка компилятора Objective-C

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]; 
+0

отформатируйте сообщение, чтобы формат кода выглядел лучше ... – ltebean

ответ

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]; 

У вас есть дополнительный '[' перед текущим и и экстра ']' после Alloc UIAlertView.

+1

На самом деле вам нужно только удалить '[' перед 'currentValue'. И в '' UIAlertView' тоже есть лишний '' '. – rmaddy

+0

Я думаю, это то, что я хотел сказать; Очистите ответ, чтобы уточнить. Благодарю. – grodier

Смежные вопросы