UILocalNotification中的非固定repeatInterval [英] non-fixed repeatInterval in UILocalNotification
问题描述
我已经在这头上挣扎了好几个星期了.
I've been cracking my head on this one for weeks now.
如果将UILocalNotification
的repeatInterval
属性设置为非固定间隔会发生什么? (不固定,我指的是诸如NSWeekdayCalendarUnit
和NSWeekdayOrdinalCalendarUnit
的单位).
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
).
假设我将UILocalNotification
的fireDate
设置为当前周的星期三,并将repeatInterval
设置为NSWeekdayCalendarUnit
.它会在每个星期三重复吗?
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?
NSWeekdayOrdinalCalendarUnit
是否相同?因此,如果我将fireDate
设置为每月第4个星期三,并且将repeatInterval
设置为NSWeekdayOrdinalCalendarUnit
,则是否每个月的第4个星期三重复一次?
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?
谢谢.
推荐答案
好的,为了所有人的利益,这就是我发现的东西:
OK, for the benefit of everyone, here's what I found:
-
将重复间隔设置为
NSWeekdayCalendarUnit
并没有达到我的预期效果,相反,我想它会查找一周内该工作日的每一次发生,并且由于只有一次,因此它安排了通知时间该周结束时(默认为星期六)
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)
以类似的方式,将其设置为NSWeekdayOrdinalCalendarUnit
会创建类似的行为,因为看到X日的X序号不再出现,因此诉诸于该工作日的las序号一个月之内.
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.
这篇关于UILocalNotification中的非固定repeatInterval的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!