Print Notifications
-
22-10-2019 - |
سؤال
How can I print every single notification on my system in obj-C?
[[NSNotificationCenter defaultCenter] addObserver:self ...];
what does in "..."? Should I use NSDistributedNotificationCenter?
let's say I have a function called logfunc which will do NSLog(@"ok");
thank you
المحلول
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMethod:) name:nil object:nil];
You can then define a method that matches your selector, like this:
- (void)myMethod:(NSNotification *)notification {
NSLog(@"notification received: %@", notification);
}
لا تنتمي إلى StackOverflow