2012-04-20 75 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;