2012-04-20 76 views
0

我在FirstViewController类中有一个NSMutable数组,我想将该数组传递给SecondViewController类。我想在SecondViewController类中使用它。我在Xcode 4.2.1中用ARC来做这个...我怎么能......?有什么属性我想设置属性时......(OR)使用使用的appdelegate文件也解释了我......NSMutable阵列从一个类到iPhone中的另一个类

回答

0

有两种方法可以做到这一点。

1:在appdelegate中为NSMutableArray创建属性,为FirstViewController中的数组设置值并在SecondViewController中检索值。

2:在SecondViewController中为NSMutableArray创建一个属性,并为FirstViewController调用此属性,但调用SecondViewController的对象,并通过FirstViewController的secondViewController的对象引用调用该属性。

+0

Thanku ...你能请解释在Xcode 4.2.1编程...我试过用你解释的方式... – SriKanth 2012-04-20 08:42:25

+0

当然,你有没有尝试1或2方法? – MrWaqasAhmed 2012-04-20 09:38:09

+0

我试过的第一种方法...但我不能访问数据... – SriKanth 2012-04-20 10:02:28

0

在当前类

#import "SecondViewController" 

SecondViewController *NextViewController = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil]; 

     NextViewController.nextClasssArray = thisClassarray; 

in second class .h

@property(nonatomic,retain) NSMutableArray *nextClasssArray; 

在第二类.M

@synthesize nextClasssArray;