Hi. Does anyone know a simple way to manage several tableViews in one viewController? Here is how I've been doing it so far:
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
if(tableView == self.tableView1)
return 1;
else if(tableView == self.tableView2)
return 2;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if(tableView == self.tableView1)
return @"bla";
else if(tableView == self.tableView2)
return @"blabla";
}
-(NSString *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(tableView == self.tableView1)
...
else if(tableView == self.tableView2)
...
}
I find it really annoying that I have to use an if/else statement for EVERY SINGLE delegate method. Plus, it is really hard to read when there are many tableViews. Besides, I have the same problem with NSURLConnection, etc... As soon as I have several objects that respond to the same delegate protocol, things get messy.
What is the best way to make things simpler? Thanks