-2

I have an array which has lots of data which is dispalyed on the TableView. I am trying to push the selected row name. So every time I have to write IF method, while every row has the same method. Is there a way to just push the selected row?

Thanks from now.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    SecondViewController *DetailViewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

    if ([[Brands objectAtIndex:indexPath.row] isEqual:@"A"]){

}

    if ([[Brands objectAtIndex:indexPath.row] isEqual:@"B"]){

}
.
.
.
Luai Kalkatawi
  • 1,492
  • 5
  • 25
  • 51

1 Answers1

0

After trying many times I found my answer. Thanks again for your responds.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

SecondViewController *push = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

NSString *detail=[Brands objectAtIndex:indexPath.row];

label.text = detail;

}

Luai Kalkatawi
  • 1,492
  • 5
  • 25
  • 51