I need to get notified when the changes made in system preference panel.From the google document I found kEventSystemTimeDateChanged and it worked in Leopard.But While running the same code snippet on snow leopard, event is not getting fired on clock changes.I need clarification does Snow Leopard and Lion supports kEventSystemTimeDateChanged.
My Code snippet is as given below.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[self SystemTimeChangeHandler];
}
OSStatus DateChangeEventHandler(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData)
{
NSLog(@"Event Fired!\n");
return 0;
}
- (void)SystemTimeChangeHandler
{
NSLog(@"SystemTimeChangeHandler");
EventTypeSpec eventType;
eventType.eventClass = kEventClassSystem;
eventType.eventKind = kEventSystemTimeDateChanged;
EventHandlerUPP eventHandlerUPP =
NewEventHandlerUPP(DateChangeEventHandler);
EventHandlerRef eventHandlerRef = NULL;
(void)InstallApplicationEventHandler(
eventHandlerUPP,
1,
&eventType,
self,
&eventHandlerRef);
}
As a workaround, in Mac OS X 10.6 or later, you can register for the NSSystemClockDidChangeNotification
. The documentation doesn't make clear whether that's on the default local notification center or the default distributed notification center.