I think you should have a property with a name different from the delegate in your popover controller, since the UITableViewController already has a delegate property for the UITableViewDelegate protocol; maybe masterTable or something like that.
Then, in the implementation of selectedObject: in the root UITableView, you can make an insert row or add it to the data array and reload table.
Oops, my bad ... @geraldWilliam is right, the UITableViewController does not have the delegation property ...
What you think should work ... So how is the selectedObject: method called in the delegate? If so, what are you doing in this method? If you add an object to a dataset (array or dictionary or database) for the root view, insert a row in its table (or reload the data), it should work.
Here is the code that works for me. This is not from a popover, but from a pushed glance, but there is no reason that should matter:
- (ThingStatus) thingPicker: (ThingPickerTableViewController *) thingPicker didSelectThing: (Thing *) thing { NSLog( @"Entering %s", __func__ ); // Dismiss the pushed view controller (for you, the popover) [self.navigationController popViewControllerAnimated: YES]; NSArray *startingList = self.currentCellObjectList; [self.databaseManager addThing: thing]; NSArray *endingList = self.databaseManager.thingsForTableView; // Figure out the differences adding made... DiffResult *changes = [startingList simpleDiffWithArray: endingList]; NSLog( @"%d deletions, %d insertions", changes.deletionCount, changes.insertionCount ); // I only handle insertions in this code... deletions would be similar __block NSUInteger objIdx = 0; NSMutableArray *changeableThingList = [startingList mutableCopy]; [changes.insertionIndexes enumerateIndexesUsingBlock: ^( NSUInteger idx, BOOL *stop ) { NSLog( @" - insert %@ at %d", [[changes.insertionObjects objectAtIndex: objIdx] name], idx ); NSIndexPath *indexPath = [NSIndexPath indexPathForRow: idx inSection: 0]; [changeableThingList insertObject: [changes.insertionObjects objectAtIndex: objIdx] atIndex: idx]; self.currentCellObjectList = changeableThingList; [self.tableView insertRowsAtIndexPaths: [NSArray arrayWithObject: indexPath] withRowAnimation: UITableViewRowAnimationRight]; ++objIdx; }]; [self.databaseManager save]; return [self.databaseManager: thingStatus];
}
source share