Question

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

Was it helpful?

Solution

[[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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top