UILocalNotification 中的非固定重复间隔
几周来我一直在为这个问题绞尽脑汁。
如果我将 UILocalNotification
的 repeatInterval
属性设置为非固定间隔,会发生什么情况? (非固定是指诸如 NSWeekdayCalendarUnit
和 NSWeekdayOrdinalCalendarUnit
之类的单位)。
假设我将 UILocalNotification
的 fireDate
设置为本周的星期三,并将 repeatInterval
设置为 NSWeekdayCalendarUnit< /代码>。每个星期三都会重复吗?
NSWeekdayOrdinalCalendarUnit
也是如此吗?因此,如果我收到一个将 fireDate
设置为该月第四个星期三的通知,并且将 repeatInterval
设置为 NSWeekdayOrdinalCalendarUnit
,将会每个月的第四个星期三重复一次?
先感谢您。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,为了大家的利益,这是我发现的:
将重复间隔设置为
NSWeekdayCalendarUnit
并不能按我的预期工作,相反,我想它会查找内部该工作日的每次出现一周,并且因为只有一个,所以它会安排该周结束时的通知(默认为星期六)以类似的方式,将其设置为
NSWeekdayOrdinalCalendarUnit
会创建类似的行为,因为看到 X 天的 X 序数不再出现,它会诉诸于调度到一个月中该工作日的 las 序数。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.