Search code examples
cocoanscalendar

Is there a notification for when the calendar changes via System Preferences?


My app draws a calendar. I have an ivar, _cal, set to -[NSCalendar autoupdatingCurrentCalendar] because I'd like to redraw the calendar if the user makes a change in System Preferences. For example, they could change the first day of week from Sunday to something else.

Currently, I'm using an NSTimer that fires every second. I check [_cal firstWeekday] against a cached copy to see if it has changed. If so, I redraw.

I'm wondering if instead there is a way for me to be notified if the System Preferences affecting the calendar have changed. Then, I could get rid of my NSTimer.


Solution

  • It looks like you can observer NSCurrentLocaleDidChangeNotification.

    See https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSLocale_Class/Reference/Reference.html#//apple_ref/doc/uid/TP30001224-DontLinkElementID_1