Objective c 错误的通知日期

Objective c 错误的通知日期,objective-c,Objective C,我正在设置通知, 我可以看到我用来设置它的NSDate是2012-10-10 08:37:55+0000 但是,当我设置通知时,它会记录另一个要触发的日期: Notification will be shown on: 2011-10-10 08:37:55 +0000 代码是: NSLog(@"mode:%d",[memoryInstance getEditMode]); NSLog(@"schedule for sound:%@",number); NSLog(@"DATE :%@",s

我正在设置通知, 我可以看到我用来设置它的NSDate是
2012-10-10 08:37:55+0000
但是,当我设置通知时,它会记录另一个要触发的日期:

 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];
发生的事情是,我的通知是在我设置它的那一刻发出的。它已经过去了。

明白了。 我必须使用yyyy作为格式化程序。 YYYY代表一年中的几周。

它不是一年中的几周,而是“年”(在基于“一年中的一周”的日历中)