IOS NSNotificationCenter 通知的使用
1.注册通知
[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notify) name:@"myNotify" object:nil];
-(void)notify
{
NSLog(@"notify");
}
2.触发通知
[NSNotificationCenter defaultCenter] postNotificationName:@"myNotify" object:nil];
3.移除通知
[NSNotificationCenter defaultCenter] removeObserver:self name:@"myNotify" object:nil];
如果使用[NSNotificationCenter defaultCenter] removeObserver:self ] 也就是没有指定 name的话,那跟self有关的所有的通知都会被移除掉,如果指定了name的话,只会移除跟name匹配的通知。
其中 object 是可以附带传递的参数。
IOS NSNotificationCenter 通知的使用的更多相关文章
- IOS中通知中心(NSNotificationCenter)
摘要 NSNotification是IOS中一个调度消息通知的类,采用单例模式设计,在程序中实现传值.回调等地方应用很广. IOS中通知中心NSNotificationCenter应用总结 一.了 ...
- iOS - Notification 通知
1.Notification 通知中心实际上是在程序内部提供了消息广播的一种机制,它允许我们在低程度耦合的情况下,满足控制器与一个任意的对象进行通信的目的.每一个 iOS 程序(即每一个进程)都有一个 ...
- IOS Notification 通知中心
1. 通知中心概述 通知中心实际上是在程序内部提供了消息广播的一种机制.通知中心不能在进程间进行通信.实际上就是一个二传手,把接收到的消息,根据内部的一个消息转发表,来将消息转发给需要的对象. ...
- IOS NSNotification 通知
一. 先看下官方对NSNotification通知的解释 1. NSNotification 通知 @interface NSNotification : NSObject <NSCopying ...
- ios 消息通知
苹果的通知分为本地通知和远程通知,这里主要说的是远程通知 历史介绍 iOS 3 - 引入推送通知UIApplication 的 registerForRemoteNotificationTypes 与 ...
- NSNotificationCenter通知中心
概述 NSNotificationCenter通知中心,通常用于一对一或者一对多的消息传递,即当一个地方改变时,要求改变其他的一些地方,例如当网络请求回来了新的数据,需要刷新本地信息和本地内存里面的界 ...
- IOS开发-通知与消息机制
在多数移动应用中不论什么时候都仅仅能有一个应用程序处于活跃状态.假设其它应用此刻发生了一些用户感兴趣的那么通过通知机制就能够告诉用户此时发生的事情. iOS中通知机制又叫消息机制,其包含两类:一类是本 ...
- IOS 本地通知 UILocalNotification
IOS 本地通知 UILocalNotification [本文章第四部分中的代码逻辑来自网上的借鉴,并非我自己原创] 大概一个月前,我开始跟着做IOS项目了.学习C++,了解Objective-C, ...
- iOS 本地通知 操作
iOS 本地通知 操作 1:配置通知:然后退出程序: UILocalNotification *localNotif = [[UILocalNotification alloc] init]; loc ...
随机推荐
- floodlight make the VMs can not getDHCP IP address
https://answers.launchpad.net/neutron/+question/242170 这个问题我也遇到了,但是没人回答. floodlight make the VMs can ...
- QT5删除隐藏目录+隐藏文件(使用Process::start函数调用系统命令,且等待到结束)
1.功能需求 删除一个目录(包括目录本身),同时删除该目录中所有文件及目录(含隐藏的) 2.遇到的问题 qt5中已经有了递归删除目录的函数--->bool QDir::removeRecursi ...
- IDEA建项目的正确姿势
今天建多模块的分布式项目的时候折腾死了,可能是建项目的方法不对,最后经过摸索,觉得这样是比较合适的: 首先建一个空的项目:Empty Project,就是项目文件夹 然后在里面建model
- java.util.zip.ZipOutputStream压缩无乱码(原创)
package io; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileI ...
- 计算机视觉和人工智能的状态:我们已经走得很远了 The state of Computer Vision and AI: we are really, really far away.
The picture above is funny. But for me it is also one of those examples that make me sad about the o ...
- Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor.
在部署的时候出现Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds. If the server ...
- C#版二维码生成器
前言 本文所使用的二维码生成代码是谷歌开源的条形码图像处理库完成的,c#版的代码可去 这里 -- 下载压缩包. 截止目前为止最新版本为2.2,提供以下编码格式的支持: UPC-A and UPC ...
- IOS ARC与非ARC混合编译
要开启ARC的:-fobjc-arc不开启ARC的:-fno-objc-arc 是否使用arc: 在build setting里找automatic reference counting,YES/NO
- ios跳转
目标应用程序:打开info.plist,添加一项URL types展开URL types,再展开Item1,将Item1下的URL identifier修改为URL Scheme展开URL Schem ...
- 连续多行输入--C++ 中字符串标准输入的学习及实验(续篇)
编程中常常会用到连续多行输入的情况,如果事先知道要输入多少行的话,可以直接定义一个变量,然后用循环就可以实现了,但有时候事先并不知道,要输入多少行,于是就可以用到输入流碰到文件终止符的情况了,具体 ...