pvi*_*nis 1 objective-c nsnotificationcenter
如何在obj-C中打印我系统上的每个通知?
[[NSNotificationCenter defaultCenter] addObserver:self ...];
Run Code Online (Sandbox Code Playgroud)
"......"中有什么用?我应该使用NSDistributedNotificationCenter吗?
假设我有一个名为logfunc的函数,它将执行NSLog(@"ok");
谢谢
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMethod:) name:nil object:nil];
Run Code Online (Sandbox Code Playgroud)
然后,您可以定义与您的选择器匹配的方法,如下所示:
- (void)myMethod:(NSNotification *)notification {
NSLog(@"notification received: %@", notification);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
498 次 |
| 最近记录: |