简体   繁体   中英

next fire date in UIlocalNotification

Hi All
I have created a UILocalNotification....& when i print it

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

it gives

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}

But I want to access the next fire date of this Notification how can i get this value?
Please any help for this.

You can't access it directly as a property, because it is calculated based on fireDate and repeatInterval.

Here is the answer to your question

How to grab the NEXT fire date from a UILocalNotification object

UILocalNotification具有您可以使用的fireDate属性。

Just use:

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

fromDate:self.localNotification.fireDate];

NSDate *nextFireDate = [calendar dateFromComponents:comps];

您可以从[self.notification description](即nsstring)中访问下一个日期,并从返回的字符串中删除不需要的字符

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM