cyclingIsBetter
cyclingIsBetter

Reputation: 17591

IOS: delegate methods for two tableView

myaI have this code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


if (tableView == firstTableView){

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil){
    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewStylePlain reuseIdentifier:CellIdentifier] autorelease] ; 
}

cell.textLabel.text = [myArray objectAtIndex:indexPath.row];

return cell;
}
}

I check if tableview is firsttableview, but it give me a warning because the method haven't a "return" cell, how can I solve?

Upvotes: 1

Views: 467

Answers (2)

RyanR
RyanR

Reputation: 7758

Your code needs to return a value for all paths through that method. So, if your check for firstTableView fails, you still need to return a valid UITableViewCell from the method. You should probably read the UITableView programming guide - it walks you through proper usage of a tableview.

Upvotes: 1

Justin
Justin

Reputation: 20609

You only return a cell if the table is firstTableView. Make sure you return a cell for other tables by adding a return statement outside of your conditional.

Upvotes: 1

Related Questions