non-fixed repeatInterval in UILocalNotification

我是研究僧i 提交于 2019-12-07 07:01:08

问题


I've been cracking my head on this one for weeks now.

What happens if I set the repeatInterval property of a UILocalNotification to be a non-fixed interval? (by non-fixed I mean units such as NSWeekdayCalendarUnit and NSWeekdayOrdinalCalendarUnit).

So say I have UILocalNotification with its fireDate set to the Wednesday in the current week, and I set the repeatInterval to be NSWeekdayCalendarUnit. Will it repeat every Wednesday?

Is the same true for NSWeekdayOrdinalCalendarUnit? So if I have a notification with the fireDate set to be the 4th Wednesday of the month, and I set the repeatInterval to be NSWeekdayOrdinalCalendarUnit, will it repeat every 4th Wednesday of every month?

Thank you in advance.


回答1:


OK, for the benefit of everyone, here's what I found:

  • Setting the repeat interval to NSWeekdayCalendarUnit doesn't work how I expected, instead, I suppose it looks for every occurrence of that weekday inside a week, and because there is only one, it then schedules the notification for the end of that week (the default is Saturday)

  • In a similar way, setting it to NSWeekdayOrdinalCalendarUnit creates a similar behavior, in that, seeing that there is no more occurrences of X ordinal of X day, it resorts to scheduling to the las ordinal for that weekday in a month.



来源:https://stackoverflow.com/questions/5986595/non-fixed-repeatinterval-in-uilocalnotification

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