IOS学习笔记之十四:NotificationCenter的使用以及注意事项
来源:互联网 发布:成都好吃网络的蛋糕店 编辑:程序博客网 时间:2024/05/29 15:55
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *lblName;
@end
@implementation ViewController
- (IBAction)addObserver:(id)sender {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(printName:) name:@"printName" object:nil];
}
- (IBAction)PostNotification:(id)sender {
[[NSNotificationCenter defaultCenter] postNotificationName:@"printName" object:@"NiKlaus"];
}
- (IBAction)removeObserver:(id)sender {
[[NSNotificationCenter defaultCenter] removeObserver:self];
dispatch_async(dispatch_get_main_queue(), ^{
self.lblName.text = @"NAME";
});
}
- (void) printName:(NSNotification*) notification {
id name = [notification object];
dispatch_async(dispatch_get_main_queue(), ^{
self.lblName.text = name;
});
}
@end
- IOS学习笔记之十四:NotificationCenter的使用以及注意事项
- NotificationCenter的基本使用
- iOS 定时器的使用以及注意事项
- poco库学习笔记(10) Poco::NotificationCenter
- IOS学习十四:网络之ASIHttpRequest和SBJson简单使用
- IOS学习十四:网络之ASIHttpRequest和SBJson简单使用
- oracle9i学习笔记之十四 使用集合运算
- iOS分享 - 对象间的通信之delegate、notificationCenter与block
- Swift-通知中心(NotificationCenter)的使用
- iOS基础知识:if 语句以及if语句的使用注意事项
- (iOS开发)UIScrollView的使用以及注意事项
- Objective-C学习-单例以及通知中心(NotificationCenter)
- MonoRail学习笔记十四:分页功能的使用
- MonoRail学习笔记十四:分页功能的使用
- struts2学习笔记(十四)——freemarker的使用
- Spring学习笔记(十四):junit4的使用
- swift学习笔记之navigationController的设置以及使用
- C++学习之使用new的注意事项
- 【学习笔记----数据结构10-二叉树】
- PE结构详解(64位和32位的差别)
- eclipse中system.out.println()出现问题,总是提示out cannot be resolved or is not a field
- 如何写nginx module
- 解决jetty运行时,出现A full JDK (not just JRE) is required问题
- IOS学习笔记之十四:NotificationCenter的使用以及注意事项
- 用 Java 生成 GUID
- PAT DS 8-04 打印学生选课清单
- 改变static值,但还是取到原来的值的原因解答
- 关于斐波那契数列小结
- 利用git将代码保存在github上
- 黑马程序员-java基础之基础知识
- Xcode自动生成项目文档
- xmpp的一些资源