void callback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
NSNotification* n = [NSNotification notificationWithName:name object:object userInfo:userInfo];
objc_msgSend(gSelf, sel_getUid(@"note:"), n);
return;
}
- (void)viewDidLoad {
[super viewDidLoad];
gSelf = self;
notifications = [[NSMutableArray alloc] initWithCapacity:10];
self.title = @"Notification Log";
CFNotificationCenterAddObserver(
CFNotificationCenterGetDarwinNotifyCenter(), //center
NULL, // observer
callback, // callback
NULL, // name
NULL, // object
CFNotificationSuspensionBehaviorHold
);
}
-(void)note:(NSNotification *)notification{
@synchronized(self){
[notifications addObject:notification];
[self.tableView reloadData];
}
}