Iphone UIlocalNotification中的下一个火灾日期
大家好 我已经创建了一个UILocalNotification…&当我打印它时Iphone UIlocalNotification中的下一个火灾日期,iphone,objective-c,notifications,Iphone,Objective C,Notifications,大家好 我已经创建了一个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),
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}
但我想访问此通知的下一个火灾日期如何获取此值?
请提供相关帮助。UILocalNotification有一个可以使用的属性。UILocalNotification有一个可以使用的属性。您不能将其作为属性直接访问,因为它是基于fireDate和repeatInterval计算的 这是你问题的答案
您不能将其作为属性直接访问,因为它是基于fireDate和repeatInterval计算的 这是你问题的答案 只需使用:
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comps = [calendar components:self.localNotification.repeatInterval
fromDate:self.localNotification.fireDate];
NSDate *nextFireDate = [calendar dateFromComponents:comps];
只需使用:
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comps = [calendar components:self.localNotification.repeatInterval
fromDate:self.localNotification.fireDate];
NSDate *nextFireDate = [calendar dateFromComponents:comps];