问题
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
NSWeekdayCalendarUnitdoesn'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
NSWeekdayOrdinalCalendarUnitcreates 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