I\'m using storyboards and I have a UITableView. I have a segue setup that pushes from my table to the detail VC. But which method should I use to handle this? I\'ll have
if your tableView property is in another class and you only have one section, then you could use the tag property to store the cell's row like:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
cell.tag = indexPath.row;
return cell;
}
And then you can access it as the sender is the same cell with the row value in its tag:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
MyDestinationViewController *destinationViewController = segue.destinationViewController;
destinationViewController.myProperty = [tableViewElementsArray objectAtIndex:[sender tag]]; // sender will be your cell
}