Instantly share code, notes, and snippets.

Embed
What would you like to do?
Log all NSNotifications as they are fired
static void LogNSNotifications(CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
CFDictionaryRef userInfo);
void LogNSNotifications(CFNotificationCenterRef center,
void *observer,
CFStringRef name,
const void *object,
CFDictionaryRef userInfo) {
NSLog(@"\n\nNotification Logged:");
NSLog(@"observer %@", [(__bridge NSObject *)observer debugDescription]);
NSLog(@"object %@", [(__bridge NSObject *)object debugDescription]);
NSLog(@"name: %@", name);
NSLog(@"userinfo: %@", userInfo);
}
// then in your app delegate, call this function:
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(),
NULL,
LogNSNotifications,
NULL,
NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment