How to get the indexPath of the particular table from multiple table in iphone

162 Views Asked by At

Hi i m using 2 tables in a single view and want to get the indexpath of the tables. I use the below code to get the indexpath. but stil categoryId getting effected whatever table i access not the other thing. Please help...

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{   
    if(tableView=categoryTblView)
    {
        categoryId=indexPath.row;
        NSLog(@"categoryId=%d",categoryId);
    }

    else if(tableView=regionTblView)
    {
        regionId=indexPath.row;
        NSLog(@"regionId=%d",regionId);
    }       
}
1

There are 1 best solutions below

0
On

To test equality here, you need to use == instead of a single equal sign (which is for assignment).

So the code should be:

if (tableView == categoryTblView)
{
    ...
}
else if (tableView == regionTblView)
{
    ...
}