1. 定义一个方法
update
2. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(update) name:@"update" object:nil]
3. 在要发出通知消息的地方
[[NSNotificationCenter defaultCenter] postNotificationName:@"update" object:nil];
看贴请回帖!
本文介绍如何使用NSNotification在Objective-C中实现解耦的通知发送与接收机制。主要步骤包括:定义更新方法、注册观察者、发送通知。
1. 定义一个方法
update
2. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(update) name:@"update" object:nil]
3. 在要发出通知消息的地方
[[NSNotificationCenter defaultCenter] postNotificationName:@"update" object:nil];
看贴请回帖!
434

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