Skip to content

Instantly share code, notes, and snippets.

@aqubi
Last active August 29, 2015 14:15
Show Gist options
  • Save aqubi/d2c85e99cbbfba2d69c8 to your computer and use it in GitHub Desktop.
Save aqubi/d2c85e99cbbfba2d69c8 to your computer and use it in GitHub Desktop.
DarwinNotifyCenter
- (void)addObserver {
CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(),
NULL,
MyCallBack,
CFSTR("MyNotificationName"),
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
}
static void MyCallBack(CFNotificationCenterRef center, void *observer, CFStringRef name,const void *object, CFDictionaryRef userInfo) {
NSLog(@"observer: %@", observer);
NSLog(@"name: %@", name);
NSLog(@"userinfo: %@", userInfo);
NSLog(@"object: %@", object);
}
- (void)postNotification {
CFNotificationCenterRef notification = CFNotificationCenterGetDarwinNotifyCenter();
CFNotificationCenterPostNotification(notification, CFSTR("MyNotificationName"), NULL, NULL, YES);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment