Feroz
Feroz

Reputation: 699

how to find section in didSelectRowAtIndexPath: method

Is it possible to find section of row where I am clicking in tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath method.

TIA

Upvotes: 2

Views: 3565

Answers (4)

Hemant Dixit
Hemant Dixit

Reputation: 1145

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:
(NSIndexPath*)indexPath{
    int section = [indexPath section];
    NSLog(@"section %d",section);
}

Upvotes: 2

Prabha
Prabha

Reputation: 434

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

   int section = [indexPath section];

}

Upvotes: 2

Vineesh TP
Vineesh TP

Reputation: 7963

-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

 if(indexPath.section==0)
 {

    // 1st Section of the tableView.

   if(indexPath.row==0)
   {

      // 1st cell of the 1st section.

   }
 }
}

Upvotes: 2

atastrophic
atastrophic

Reputation: 3143

the indexPath parameter has section property accessible as following

[indexPath section]; 

OR

indexPath.section

Upvotes: 10

Related Questions