zoukankan      html  css  js  c++  java
  • 通知机制

    通知

      1.建立通知中心

        NSNotificationCenter *center = [NSNotificationCenterdefaultCenter];

      2.利用通知中心发通知

        2.1创建一个通知对象

        NSNotification *note = [NSNotificationnotificationWithName:@"tech_new"object:tx];

        2.2利用通知中心,将这则通知发出去   

        [center postNotification:note];

      3.监听通知中心发出的通知

      [center addObserver:p selector:@selector(gotNews) name:@"tech_new" object:tx];

      4.创建通知对象的时候可以带上一个属性useinfo  ----->是这则通知的详情

          NSNotification *note = [NSNotificationnotificationWithName:@"tech_new"object:tx userInfo:@{

                     @"title" : @"今天天气真好",

                      @"source" : @"腾讯网"

                                    }];

      5.通知不要重复添加。

      6.移除通知 (arc不用移除)

      [ceter remove:p];

      [ceter remove:p name:@"tech_news" object:tx];

  • 相关阅读:
    转贴:CSS伪类与CSS伪元素的区别及由来具体说明
    Docker + Consul 多数据中心模拟
    Spring之事件发布系统
    ExecutorService的submit方法的坑
    固定频率调用接口方案
    叠罗汉III之推箱子
    叠罗汉II
    叠罗汉I
    滑雪
    华为OJ:火车进站
  • 原文地址:https://www.cnblogs.com/yinqiang/p/3459305.html
Copyright © 2011-2022 走看看