Skip to content

Instantly share code, notes, and snippets.

//I also found that you can do:
//To register for change events:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleWhateverChange) name:@"whateverChange" object:nil];
//To fire them. I might be a N00b but I just couldn't get the observer for key path thing to work for me.
[[NSNotificationCenter defaultCenter] postNotificationName:@"whateverChange" object:nil];
NSUserNotification *notification = [[NSUserNotification alloc] init];
[notification setTitle:@"Hello World"];
[notification setInformativeText:@"Hello world message"];
[notification setDeliveryDate:[NSDate dateWithTimeInterval:20 sinceDate:[NSDate date]]];
[notification setSoundName:NSUserNotificationDefaultSoundName];
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
[center scheduleNotification:notification];