通知

来源:互联网 发布:电力电子研究生知乎 编辑:程序博客网 时间:2024/06/11 18:33

基本内容
NSNotificationCenter *center = [NSNotificationCenter defaultCen*强调内容*ter];【创建通知中心】
NSNotification *note = [NSNotification notificationWithName:发出的通知的名字
object:发出通知的对象 userInfo:@{@"XXX":@"XXC" @"des":@"666666666666666"}];【发出的通知具体内容】
[center postNotification:note];
[center addObserver:监听通知的对象
selector:@selector(监听到通知的回调:)【通知回调的参数传入的是通知的对象 通过【参数 object】解包通知对象发出的通知信息】
name:通知的名字
object:发出通知的对象【如果是nil,则可以接收任何对象发出的通知】];

0 0
原创粉丝点击