我正在使用UILocalNotifications实现一个提醒应用程序,并希望允许用户设置重复模式。对于重复模式,使用了NSDayCalenderUnit、NSWeekCalendarUnit等。
我没有看到LocalNotification类中有任何属性可以从通知中获取下一个火灾日期。
示例
“{火灾日期=2013年9月6日星期五,印度标准时间上午7:05:00,时区=亚洲/加尔各答(GMT+05:30)偏移19800,重复间隔= NSWeekCalendarUnit,重复计数= UILocalNotificationInfiniteRepeatCount,下一次火灾日期=2013年9月6日星期五,印度标准时间上午7:05:00,用户信息= {\n kRemindMeNotificationDataKey =\“测试通知”;\n}“
任何一个人请帮助我从当地的通知中得到下一个火灾日期。
提前谢谢。
发布于 2013-09-05 12:51:03
您可以使用UILocalNotification中的两个属性:
基于这两个属性创建一个NSDate。
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comps = [calendar components:self.localNotification.repeatInterval fromDate:self.localNotification.fireDate];
NSDate *nextFireDate = [calendar dateFromComponents:comps];发布于 2013-10-07 04:43:46
试试这段代码
NSCalendar *calendar = notification.repeatCalendar;
components.week = 1;
if (!calendar) {
calendar = [NSCalendar currentCalendar];
}
NSDate *nextFireDate = [calendar dateByAddingComponents:components toDate:notification.fireDate options:0];https://stackoverflow.com/questions/18636605
复制相似问题