14

I have a segue linked from a UITableViewCell to another UITableViewController within a navigation controller, and I need to setup the second UITableViewController based on the cell I'm segueing from.

The didSelectRowAtIndexPath method gives me that information but it gets called AFTER the prepareForSegue so I can't get the information I need in time.

I tried a couple of different things:

I've tried dragging a segue from another area on the first UITableViewController so I can just call the segue in code in the didSelectRowAtIndexPath method, but nothing seems to "stick".

There doesn't seem to be a way to just get the row and section from the UITableViewCell (it's the 'sender' in the prepareForSegue), unless I've missed something.

sickagain
  • 143
  • 1
  • 4

1 Answers1

31

In prepareForSegue:, the table view's indexPathForSelectedRow will be the path of the tapped row, if your segues are coming straight from the cells.

Or, you can use the table view's indexPathForCell: method.

jrturton
  • 118,105
  • 32
  • 252
  • 268