//A发送通知
//postNotificationName:通知名
//userInfo: 传递的参数,必须是字典类型
[[NSNotificationCenter
defaultCenter]
postNotificationName:@"down"
object:self
userInfo:dic];
//B注册通知,从通知中心获取 A 发送的通知
//addObserver 给谁注册通知
//selector 收到这个 name
的通知后 要回调的函数
//如果 name 的名字写为 nil 的话 这个通知将能接受到人格人发送的通知消息
[[NSNotificationCenter
defaultCenter]addObserver:self
selector:@selector(_pageNum:)
name:@"Up"
object:nil];
本文详细介绍了iOS中NSNotificationCenter的使用方法,包括如何发送通知、注册接收通知及回调函数的设置。通过具体代码示例展示了如何利用NSNotificationCenter实现组件间的解耦通信。
3769

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



