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

时间:2012-01-25 05:28:40

标签: iphone

我在NSInteger中有一个变量,我想从FirstViewController传递给SecondViewController。在ViewDidload的FirstViewController我有这个

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

NSLog正好显示了我想传递的内容。我的问题是如何在SecondViewController中检索传递的值。

2 个答案:

答案 0 :(得分:3)

在SecondViewController中,您只需拨打self.integer2

即可

答案 1 :(得分:2)

integer2中设置SecondViewController的属性,并在self.integer2中使用SecondViewController