How to set the repeat UILocal Notifications on the select list of Weekdays

可紊 提交于 2019-11-27 22:30:36

The API for UILocalNotification is very limited in this regard - you'll have to manually schedule 4 events repeating weekly on the days that the user selects.

An example of scheduling a repeat timer for monday would look like this

NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.weekday = 2; // sunday = 1 ... saturday = 7
dateComponents.hour    = 10;

UILocalNotification *notification = //...
notification.repeatInterval = NSWeekCalendarUnit;
notification.fireDate       = [calendar dateFromComponents:dateComponents];

The day numbers can be found in the NSDateComponents Class Reference

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