У меня проблемы при попытке запланировать UILocalNotification с использованием следующего кода:
- (IBAction) createNotification {
//Just to verify button called the method
NSLog(@"createNotification");
NSString *dateString = dateTextField.text;
NSString *textString = textTextField.text;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MM-dd-yyyy HH:mm"];
[formatter setTimeZone: [NSTimeZone defaultTimeZone]];
NSDate *alertTime = [formatter dateFromString:dateString];
UIApplication *app = [UIApplication sharedApplication];
UILocalNotification *notification = [[[UILocalNotification alloc] init] autorelease];
if(notification){
notification.fireDate = alertTime;
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.repeatInterval = 0;
notification.alertBody = textString;
[app scheduleLocalNotification:notification];
NSLog(@"%@", dateString);
}
}
Код вызывается правильно, когда я нажимаю кнопку, и я передаю следующую строку даты:
02-12-2012 19: 01
02/12/2012 19: 01
но безрезультатно.(Я меняю время соответственно в зависимости от времени тестирования, например, 21:06)
Может кто-нибудь объяснить, почему не отображается локальное уведомление?
Заранее спасибо,
Jack