xcode - Load three UITableViews from different datasources -
i have 3 uitableviews on view.
i have created 3 different nsmutablearray loaded different data.
i need place 1 of nsmutablearray datasource 1 of uitableview.
i able assign 3 uitableviews datasource through viewdidload of form.
but need do, assign each of uitableview datasource different nsmutablearray.
how can perform task?
thanks
tony
if 3 uitableviews share same datasource object (the object holds 3 of arrays), use if statements differentiate between table views asking data:
- (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { // if table 1 asking, give table 1 data... if (tableview == mytableview1) { // assume sections have 3 rows each // purposes of simple demonstration... return [datasourcefortable1 count]; } // if table 2 asking, give table 2 data... if (tableview == mytableview2) { // assume sections have 3 rows each // purposes of simple demonstration... return [datasourcefortable2 count]; } // if table 3 asking, give table 3 data... if (tableview == mytableview3) { // assume sections have 3 rows each // purposes of simple demonstration... return [datasourcefortable3 count]; } // compiler complain if don't have // final return since it's possible none of // if statements true ... return 0; }
Comments
Post a Comment