Skip to content

Instantly share code, notes, and snippets.

@beny
Last active December 20, 2015 05:19
Show Gist options
  • Save beny/6077418 to your computer and use it in GitHub Desktop.
Save beny/6077418 to your computer and use it in GitHub Desktop.
Simple specific NSNotification logger
void NotificationLogger(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
NSString *notificationName = (__bridge NSString *)name;
NSRange prefixRange = [notificationName rangeOfString:@"OB"];
NSArray *excludeNotifications = @[@"OBNotInterestingNotification"];
if (prefixRange.location != NSNotFound && prefixRange.length != 0) {]) {
NSLog(@"Notification send %@ with userInfo %@", name, userInfo);
}
}
...
// put this into application:didFinishLaunchingWithOptions: for example
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), NULL, NotificationLogger, NULL, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment