下一个火日期

问题描述:

大家好
我创建了一个UILocalNotification .... &当我打印下一个火日期

NSLog(@"Notification %@",self.notification) 

它给

Notification <UIConcreteLocalNotification: 0x6f45440> 
{fire date = 2010-10-22 00:09:00 -0700, time zone = America/Vancouver (PDT) offset -25200 
(Daylight), repeat interval = 64, **next fire date** = 2010-10-22 00:10:00 -0700} 

但我想访问下一个火此通知的日期如何获得此值?
请任何帮助这一点。

可以从返回的字符串

+2

解析对象的描述*从未*一个好主意,因为该格式可以在改变未来并破坏你的代码。相反,总是试图使用记录的属性和方法,以获得您所需要的信息。 – 2010-12-01 16:47:53

UILocalNotification有一个fireDate属性,您可以使用访问从[self.notification描述]下一个日期是NSString的和删除不需要的字符。

您无法直接访问它的属性,因为它是基于fireDate和按repeatInterval计算。

这里是回答你的问题

How to grab the NEXT fire date from a UILocalNotification object

只需使用:

NSCalendar *calendar = [NSCalendar currentCalendar];  
NSDateComponents *comps = [calendar components:self.localNotification.repeatInterval 

fromDate:self.localNotification.fireDate]; 

NSDate *nextFireDate = [calendar dateFromComponents:comps];