我正在设置通知,我可以看到我用来设置它的 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];
发生的事情是我的通知是在我设置它的那一刻出现的。它在过去。