IOS - data transfer in pushed viewcontroller

When you click on the viewcontroller, how can I also transfer data along with it (for example, "asdf": 123)? Do you want to add objects to NSBundle?

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

And in your MyViewController class:

.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" } 
+16
source

I do not believe that you can, but, of course, you can add the appropriate properties or methods to your ViewController class and use them before you click it.

+1
source

Not. You can equate NSBundle with Android Bundle , but they are not connected and do not perform similar tasks. Clafou correctly suggests passing data using methods and properties.

0
source

Source: https://habr.com/ru/post/900610/


All Articles