views:

55

answers:

1

I've got the following code in one of my view controllers:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.section) {
      case 0: // "days" section tapped
      {     DayPicker *dayPicker = [[DayPicker alloc] initWithStyle:UITableViewStylePlain];
           dayPicker.rowLabel = self.activeDaysLabel;
           dayPicker.selectedDays = self.newRule.activeDays;
           [self.navigationController pushViewController:dayPicker animated:YES];
           [dayPicker release];
           break;

...

Then, in the DayPicker controller, I do some stuff to the dayPicker.rowLabel property. Now, when the dayPicker is dismissed, I want the value in dayPicker.rowLabel to be used as the cell.textLabel.text property in the cell that called the controller in the first place (i.e., the cell label becomes the option that was selected within the DayPicker controller).

I thought that by using the assignment operator to set dayPicker.rowLabel = self.activeDaysLabel, the two pointed to the same object in memory, and that upon dismissing the DayPicker, my first view controller, which uses self.activeDaysLabel as the cell.textLabel.text property for the cell in question, would automagically pick up the new value of the object. But no such luck.

Have I missed something basic here, or am I going about this the wrong way? I originally passed a reference to the calling view controller to the child view controller, but several here told me that was likely to cause problems, being a circular reference. That setup worked, though; now I'm not sure how to accomplish the same thing "the right way."

As usual, thanks in advance for your help.

A: 

Turns out I needed to add a call to

[self.tableView reloadData];

in the viewWillAppear method to get the table to read the new value.

Andy