ios通知使用小结

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

  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