In iOS 7.0 the NSWeekCalendarUnit has been deprecated. The documentation says it has to be replaced:

Use NSCalendarUnitWeekOfMonth or NSCalendarUnitWeekOfYear, depending on which you mean

I am using NSWeekCalendarUnit for weekly reminders, which one do I have to pick to get the same meaning? I dont understand the difference between NSCalendarUnitWeekOfMonth and NSCalendarUnitWeekOfYear.

Someone has asked the same question here on SO, without an convincing answer.

It quite confusing. Next week is in my understanding atomic. Today is Sun 30 March 2014. Hence Next week will always be Sun 6 March 2014. How could that change from a month or year perspective?

有帮助吗?

解决方案

If you were using NSWeekCalendarUnit to trigger a weekly reminder, replace it with NSCalendarUnitWeekOfYear:

if (days == 7) localNotif.repeatInterval = NSWeekCalendarUnit;        // deprecated
if (days == 7) localNotif.repeatInterval = NSCalendarUnitWeekOfYear;

You should find your weekly notification still works correctly.

Apple's documentation should be updated to provide guidance on the appropriate replacement.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top