iOS – 将数据传递给推送的viewcontroller

前端之家收集整理的这篇文章主要介绍了iOS – 将数据传递给推送的viewcontroller前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
推送视图控制器时,如何使用它传递数据(例如“asdf”:123)?你应该将addObjects添加到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相关文章