iOS 通知传值(顺传)
来源:互联网 发布:ubuntu开机花屏 编辑:程序博客网 时间:2024/03/29 18:59
每天10点下班,没有加班费,没有补助,请假还扣工资,这日子没法过了,日子没法过了,但是要不断复习前面的知识,否则,她就和你@“分手”;
接下来我把通知传值得方法复习一下,虽然简单,但是实用;
少说废话,上代码:
首先有两个控制器:
ViewController和 SecondViewController;实现将 ViewController里面的值传到 SecondViewController 里;
ViewController.h
#import "ViewController.h"#import "SecondViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad];}- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ SecondViewController *secondVC = [[SecondViewController alloc] init]; [self presentViewController:secondVC animated:YES completion:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:@"SecondViewControllerCenter" object:@"AirZilong"];}
SecondViewController.h
#import "SecondViewController.h"@interface SecondViewController ()@end@implementation SecondViewController- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor greenColor]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getObjecgt:) name:@"SecondViewControllerCenter" object:nil];}- (void)getObjecgt:(NSNotification *)notification{ NSLog(@"notification.object = %@",notification.object);}
打印结果:
2016-04-13 00:16:07.025 Test-Notification[8044:68675] notification.object = AirZilong
如果转载请注明转于:AirZilong的博客
3 0
- iOS 通知传值(顺传)
- iOS通知传值
- iOS通知传值
- IOS 通知传值
- iOS 通知传值
- iOS通知传值
- iOS通知传值
- iOS 通知传值
- iOS通知传值
- iOS通知传值
- iOS-通知传值
- IOS 通知传值
- iOS 通知传值(逆传)
- ios开发-通知传值
- iOS NSNotification 通知传值
- iOS通知如何传值?
- iOS NSNotification 通知传值
- iOS开发 通知传值
- C++第三次作业
- bzoj3170【TJOI2013】松鼠聚会
- 二分算法problem1001
- 切入业务日志
- LeetCode 160. Intersection of Two Linked Lists
- iOS 通知传值(顺传)
- bzoj2705【SDOI2012】Longge的问题
- ios pickerview选择城市
- Android ListView实现上拉到底部的时候自动刷新数据
- 98%的人没解出的德国面试逻辑题(离散数学篇)!?
- win10 wamp 无法启动 红色
- bzoj3004 吊灯
- javascript函数apply的使用和理解
- 关于python3.2的'dict' object has no attribute 'iteritems'