Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - UIStoryboardSegue detecting table cell and opening a viewController?

So I have a UITableView, and the cells are connected to a UIStoryboardSegue in order to open a new UIViewController. After clicking a cell prepareForSegue get's called and everything works fine.

QUESTION: In the follwoing method how can i know what is the indexPath of the selected cell in my TableView?

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    ObjectDetailViewController *mvc = [segue destinationViewController];
    // PassingObject *obj = [self.array objectAtIndex: ? ];
    mvc.passingObject = obj;
}
like image 352
aryaxt Avatar asked Feb 21 '12 01:02

aryaxt


1 Answers

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Assume self.view is the table view
    NSIndexPath *path = [self.tableView indexPathForSelectedRow];
    DetailObject *detail = [self detailForIndexPath:path];
    [segue.destinationViewController setDetail:detail];
}
like image 174
DJPlayer Avatar answered Sep 28 '22 08:09

DJPlayer