如何收听广播
1
在广播中心注册
[NSNotificationCenter defaultCenter]
- (void)addObserver:(id)observer
selector:(SEl)methodToInvokeIfSomethingHappens
name:(NSString *)name
object:(id)sender;
-(void)methodtoinvokeifsomethinghappens:(nsnotification *)notofication
{
notification.name
notification.object
notification.userinfo
}
2 关闭广播
[center removeObserver:self];
or
[center removeObserver:self name:UIContentSizeCategoryDidChangeNotification object :nil];
本文介绍了如何使用广播通知中心来监听和响应系统级的通知。包括如何注册为观察者以接收特定的通知名称,以及如何从通知中心移除观察者。通过这些步骤可以实现不同组件之间的解耦通信。

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



