0
我設置的通知, 我可以看到我使用的NSDate將其設置爲2012-10-10 08:37:55 +0000
但是,那麼它的NSLog另一個日期火的時候,我設置的通知:錯誤通知日期
Notification will be shown on: 2011-10-10 08:37:55 +0000
的代碼是:
NSLog(@"mode:%d",[memoryInstance getEditMode]);
NSLog(@"schedule for sound:%@",number);
NSLog(@"DATE :%@",self.date); //different from the one comes next
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
NSDateFormatter *dateFormat = [[[NSDateFormatter alloc]init] autorelease] ;
[dateFormat setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
NSString *dateString = [dateFormat stringFromDate:self.date]; //!!
NSDate *notificationDate = [dateFormat dateFromString:dateString];
localNotification.fireDate = notificationDate;
NSLog(@"Notification will be shown on: %@",localNotification.fireDate); //different!
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = [NSString stringWithFormat:
@"You have something to do.."];
localNotification.alertAction = NSLocalizedString(@"View details", nil);
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:number forKey:kTimerNameKey];
localNotification.userInfo=userInfo;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber =-1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
最新情況是,我的通知是在我設置它的時刻。它在過去。
這不是**每週**,它是 *'年(在「基於年的周」基於日曆)* * [日期格式模式](http://www.unicode.org/report/tr35/ tr35-10.html#Date_Format_Patterns) – Jay