Last active
December 20, 2015 05:19
-
-
Save beny/6077418 to your computer and use it in GitHub Desktop.
Simple specific NSNotification logger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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