通知使用

2017-12-26  本文已影响0人  梁苏珍

创建对象

NSNotification *notification =[NSNotification notificationWithName:@"touxiang" object:nil userInfo:dic];

    [[NSNotificationCenter defaultCenter] postNotification:notification];

移除通知

[[NSNotificationCenter defaultCenter] removeObserver:self];或者

[[NSNotificationCenter defaultCenter] removeObserver:self name:@"tongzhi" object:nil];

接受通知

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(InfoNotificationAction:) name:@"tongzhi" object:nil];

- (void)InfoNotificationAction:(NSNotification *)notification{

 NSLog(@"%@",notification.userInfo);

}

上一篇 下一篇

猜你喜欢

热点阅读