dateTimePicker.dateから時刻/日付を取得すると、通知は機能しますが、dateFromStringを使用して日付を起動すると、通知は機能しません。
コード:
-(IBAction)alarmSetButtonTapped:(id)sender {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.locale = [NSLocale systemLocale];
dateFormatter.timeStyle = NSDateFormatterShortStyle;
dateFormatter.dateStyle = NSDateFormatterShortStyle;
NSString *tmp = @"2012-09-05 10:19";
[dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
NSDate *dateFromString = [dateFormatter dateFromString: tmp];
NSLog(@"Alarm TMP %@", dateFromString);
[dateFormatter release];
[self scheduleLocalNotificationWithDate:dateFromString];
[self presentMessage:@"Alarm set"];
};
助けてくれますか??
編集:
-(void) scheduleLocalNotificationWithDate:(NSDate *)fireDate {
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = fireDate;
notification.alertBody = @"Time to wake up";
notification.soundName = @"clock.mp3";
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
[notification release];
}