views:

29

answers:

2

I have a main View that has a table which has it's own controller. How can I pass an array from the main controller to the table controller? (I use interface builder maybe i need to init the view programatically?)

A: 

Even using the interface builder, you still need a class to inherit from UITableViewController and hold the UITableView there, right? So, you can pass the array into this class's instance. Then you can use methods like:

 – tableView:cellForRowAtIndexPath:  required method

 – numberOfSectionsInTableView:

 – tableView:numberOfRowsInSection:  required method

to create the content for your UITableViewController

vodkhang
A: 

Overwrite

- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style 

in your UITableView Controller with

- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style passArray:(NSArray*)myArray{

And use that to initialise your UITableViewController passing your array in.

Robert Redmond
do should I put this? in viewDidLoad in the main view file? the table already shows up (without my data) even without being initialized in the code.
Yazzmi