Search code examples
iosobjective-cuitableviewnsindexpath

Get indexes of row and section with multiple sections?


I want a specific section indexPath but this code only give me section 0 indexPath because InSection I set 0. if there is multiple section then how i get indexPath?

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection:0];

help me with that.


Solution

  • If you click on button the below code is useful

    -(IBAction)btnClicked:(id)sender
    {
        CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:tableviewName];
    
        NSIndexPath *indexPath = [self.accountTablView indexPathForRowAtPoint:buttonPosition];
    
        NSLog(@"section index-----%ld",(long)indexPath.section);
    }