문제

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top