【问题标题】:next fire date in UIlocalNotificationUIlocalNotification 中的下一个触发日期
【发布时间】:2010-10-21 06:39:39
【问题描述】:

大家好
我创建了一个 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}

但我想访问此通知的下一个触发日期,我如何才能获得此值?
请为此提供任何帮助。

【问题讨论】:

    标签: iphone objective-c notifications


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      您不能直接将其作为属性访问,因为它是根据 fireDate 和 repeatInterval 计算得出的。

      这是您问题的答案

      How to grab the NEXT fire date from a UILocalNotification object

      【讨论】:

        【解决方案3】:

        只需使用:

        NSCalendar *calendar = [NSCalendar currentCalendar];    
        NSDateComponents *comps = [calendar components:self.localNotification.repeatInterval 
        
        fromDate:self.localNotification.fireDate];
        
        NSDate *nextFireDate = [calendar dateFromComponents:comps];
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-11-11
          • 1970-01-01
          • 2013-03-16
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多