ios - Is using tableView:willSelectedRowAtIndexPath: correct way to pass variable? -


Hello, I'm trying to pass variables to segue

I passed with tableView getting to the variable .: WillSelectedRowAtIndexPath: this is the right way? If it is not so, how should I get it? (Note: It is working like this.)

  - (NSIndexPath *) tableView: (UITableView *) tableView willSelectRowAtIndexPath: (NSIndexPath *) indexPath {selectedCoffeeShop = [coffeeshops objectAtIndex: indexPath .row]; Return index; } - (void) prepareForSegue: (UIStoryboardSegue *) segue this: (id) This {if ([isEqualToString segue.identifier: @ "coffeeShopDetailSegue"]) {CoffeeShopDetailViewController * controller = (CoffeeShopDetailViewController *) segue.destinationViewController; [Destination destination viewer]; Controller Coffee Shop = Selected Coffee Shop; }}  

After

is done only with your segue cell, then there is no need or so to apply willSelectRowAtIndexPath or didSelectRowAtIndexPath. You only need to prepareForSegue: This: Since this logic will be the cell, and you can use it to get the indexPath you need,

  - (zero) prepareForSegue: (UIStoryboardSegue *) segue this: (UITableViewCell *) this {if ([isEqualToString segue.identifier: @ "coffeeShopDetailSegue"]) {NSInteger line = [self.tableView indexPathForCell: this] .row; CoffeeShopDetailViewController * controller = segue.destinationViewController; Controller Coffee Shop = Coffee Shop [Row]; }}  

Comments