简体   繁体   English

在视图控制器之间传递变量

[英]passing variable between view controllers

i'm having a variable in NSInteger which i want to pass from FirstViewController to SecondViewController. 我在NSInteger中有一个变量,我想从FirstViewController传递给SecondViewController。 In viewDidload of FirstViewController i have this 在FirstViewController的viewDidload中,我有这个

SecondViewController*detail = [self.storyboard instantiateViewControllerWithIdentifier:@"Second"];
    detail.integer2= self.integer1;
    NSLog(@"VARIABLE PASSED----%d",detail.integer2 );

NSLog is showing exactly what i want to pass. NSLog恰好显示了我想要通过的内容。 my question is how can i retrieve passed value in SecondViewController. 我的问题是如何在SecondViewController中检索传递的值。

在您的SecondViewController中,您可以仅调用self.integer2

使物业integer2SecondViewController和使用self.integer2SecondViewController

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM