Skip to content

Instantly share code, notes, and snippets.

@DavidNix
Last active December 30, 2022 10:58
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save DavidNix/9596c2083380b50931e3 to your computer and use it in GitHub Desktop.
Save DavidNix/9596c2083380b50931e3 to your computer and use it in GitHub Desktop.
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