用法:
[[NSNotificationCenter defaultCenter] postNotificationName:@"事件名称" object:nil];
//发出通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(abc:) name:@"事件名称" object:nil];
//接收受通知
object: 可以跟参数。
在接收到通知后进入 abc: 方法。
//最后移除通知
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
本文介绍了NSNotification在iOS开发中的基本用法,包括如何发送、接收NSNotification,以及如何传递参数和解除观察者。
2018

被折叠的 条评论
为什么被折叠?



