本文介绍了iOS - 将数据传递给推送的viewcontroller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

推送视图控制器时,如何使用它传递数据(例如asdf:123)?你应该将addObjects添加到NSBundle吗?

When pushing a viewcontroller, how do I pass data long with it as well (such as "asdf":123)? Are you supposed to addObjects to a NSBundle?

推荐答案

MyViewController * myVC = [[MyViewController alloc] initWithNibName:nil bundle:nil];
myVC.someProperty = someValue;    // Pass your data here
[self.navigationController pushViewController:myVC animated:YES];

MyViewController 类中:

.h

@interface MyViewController : UIViewController
@property (nonatomic, strong) NSString * someProperty;
@end

.m

@implementation MyViewController

    - (void)viewDidLoad {
        [super viewDidLoad];
        // your data has been set
        // self.someProperty is equal to "some value"
    }

这篇关于iOS - 将数据传递给推送的viewcontroller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 10:29