2

I want to push the section title of a UITableView to another view controller's section title. But I can't figure out a way to read an existing section title. The existing section title is dynamically constructed and I'd rather reuse it than reconstructing it again.

 if (indexPath.section == 0) {

      SecondViewController *secondViewController = [[SecondViewController alloc] init];
      secondViewController.strValueHolder = FOO_section.sectionTitle; // FOO Code
      [[self navigationController] pushViewController:secondViewController animated:YES];
      [secondViewController release];

 }
Lauren Quantrell
  • 2,647
  • 6
  • 36
  • 49

1 Answers1

8

You can call the titleForHeaderInSection method directly:

NSString *sectionTitle = 
    [self tableView:tableView titleForHeaderInSection:indexPath.section];

or move the code you currently have in titleForHeaderInSection to a custom method and call that custom method from titleForHeaderInSection and the place where you are pushing another view controller.