2015-10-14 3 views
0

Я столкнулся с ошибкой, когда была нажата кнопка предупреждения. Ошибка - это несовместимый указатель на массив со строкой.Как отображать дату и время в поле оповещения

2015-10-14 12:41:06.235 snadwitch2[1974:56154] -[__NSArrayI length]: unrecognized selector sent to instance 0x7f954e918e60 
    2015-10-14 12:41:06.239 snadwitch2[1974:56154] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x7f954e918e60' 

Код окно предупреждения является

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Wait" message:@ [@"The current date and time is: %@", [NSDate date]] delegate:self cancelButtonTitle:@"Delete" otherButtonTitles:@"Cancel",nil]; 
     [alert show]; 

ответ

5

Вы передаете массив вместо строки. Вам необходимо:

NSString *message = [NSString stringWithFormat:@"The current date and time is: %@", [NSDate date]]; 
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Wait" 
    message:message 
    delegate:self 
    cancelButtonTitle:@"Delete" 
    otherButtonTitles:@"Cancel",nil]; 
[alert show]; 
Смежные вопросы