How can I skip the first occurrence of a repeating UNCalendarNotificationTrigger?

橙三吉。 提交于 2019-11-27 23:41:11

问题


Say today is a Monday and it's 1 PM. I want to schedule a weekly local notification from my iOS app starting today at 2 PM. I'd do this:

NSDateComponents *components = [[[NSDateComponents alloc]init]autorelease];
components.weekday = 2;
components.hour = 14;
components.minute = 0;

UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:components repeats:YES];
//then make a UNMutableNotificationContent and UNNotificationRequest and schedule it

But if I want to start it next Monday at 2 PM, how do I skip the first occurrence?

To ask the question another way, how do I schedule a repeating UNCalendarNotificationTrigger starting at some arbitrary time, instead of the first occurrence of the repeat interval?

来源:https://stackoverflow.com/questions/41449749/how-can-i-skip-the-first-occurrence-of-a-repeating-uncalendarnotificationtrigger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!