ios通知使用小结

时间:2021-05-17 22:41:56   收藏:0   阅读:35

  通知在开发中用的比较多,主要用于页面之间传值,今天结合文档,整理小结一下。

  1、在通知中心发送消息,主要通过名字区分,有参数的话可以用第二种方式

  [[NSNotificationCenter defaultCenter] postNotificationName:@"CCHighSeasPoolUperPageRefresh" object:nil];

  //[[NSNotificationCenter defaultCenter]postNotificationName:@"CCHighSeasPoolUperPageRefresh" object:self userInfo:nil];

  2、在通知中心注册同名的观察者,并实现选择器方法

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

  3、删除通知

  [[NSNotificationCenter defaultCenter]removeObserver:self];

  

原文:https://www.cnblogs.com/bigant9527/p/14777669.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!