Difference between NSCalendarUnitWeekOfYear & NSCalendarUnitWeekOfMonth

后端 未结 2 1322
暖寄归人
暖寄归人 2020-12-18 23:47

I want to make a UILocalNotification repeat every week, before iOS7 I would use localNotification.repeatInterval = NSWeekCalendarUnit - except

2条回答
  •  没有蜡笔的小新
    2020-12-19 00:20

    These don't appear to be documented but most likely NSCalendarUnitWeekOfYear will be a value from 1-53 (or maybe 0-52) representing the week number within the calendar year while NSCalendarUnitWeekOfMonth will be 1-5 (or maybe 0-4) representing the week within the month.

    This all assumes Gregorian calendar. I can't speak to other calendar types.

    It seems that NSCalendarUnitWeekOfMonth is equal to kCFCalendarUnitWeekOfMonth which is defined as "Specifies the original week of a month calendar unit." and NSCalendarUnitWeekOfYear is equal to kCFCalendarUnitWeekOfYear which is defined as "Specifies the original week of the year calendar unit.".

提交回复
热议问题