2016-02-27 33 views
0

拾取器的陣列要使用從NSObject類擴展的類。這個類將有一個樹屬性。我想爲這些對象賦值。那麼如何創建該類的許多對象並將這些對象作爲數組傳遞給選取器?我如何類對象作爲目標C

以下是我的三個陣列。我想在我的班級作爲屬性

[email protected][@"apple.jpg",@"banana.jpg",@"grapes.jpg",@"strawberry.jpg",@"watermelon.jpg"]; 

[email protected][@"apple",@"banana",@"grapes",@"strawberry",@"watermelon"]; 

[email protected][@"Apple is contain the vitamin A. Apple comes from kasmir.",@"Banana is very healthy. Banana contain more calaris than any other fruit. ",@"Grapes are mostly use to make the wine and grapes are having two types green and black.",@"strawberry is the sweet fruit and mostly comes in the cold environment.",@"watermelon is fruit which does not have the trees like other fruits. They are having the climber. "]; 

如何做到這一點?

+0

只是用於循環,該對象賦值。 –

+0

以及如何將其傳遞給選取器示例代碼(如果有的話)? –

回答

1
  1. 要求特性創建自定義類。
  2. 創建新的可變數組,例如水果
  3. 在for循環中,使用上述的數組數據創建自定義類對象並將值分配給屬性。 這個自定義對象添加到新的可變數組(這裏的水果)。所有的物體會通過一個for循環
  4. 使用添加了一個數組作爲選擇器的數據源。爲了填補選擇器值,你可以訪問自定義對象的屬性,在果陣

你可以參考UIPickerView with NSDictionary