Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace deprecated NSWeekCalendarUnit in context of UILocalNotification?

Tags:

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?

like image 851
Houman Avatar asked Mar 30 '14 13:03

Houman


1 Answers

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.

like image 188
russes Avatar answered Oct 12 '22 10:10

russes