Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing an int from MasterView to DetailView in a UISplitViewController
    text
    copied!<p>I have a UISplitViewController in which i'm attempting to pass an int value from the MasterViewController to a DetailTableViewController. Both the master and the detail view controller are UITableViewControllers. I am attempting to pass the indexPath.row value from the master to the detail which will dictate which array of objects is loaded into the detailViewController's tableview. </p> <p>Some code from MasterViewController.m</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int indexRowTouched = indexPath.row; detailViewController = [self.splitViewController.viewControllers lastObject]; NSLog(@"%@", detailViewController); detailViewController.detailItem = indexRowTouched; NSLog(@"index row %i", indexRowTouched); } </code></pre> <p>An exception is thrown here</p> <pre><code>detailViewController.detailItem = indexRowTouched; </code></pre> <p>2012-03-28 16:08:19.625 splittest2[14895:f803] -[UINavigationController setDetailItem:]: unrecognized selector sent to instance 0x6b592e0</p> <p>From the DetailViewController.m</p> <pre><code>- (void)setDetailItem:(int)newDetailItem { if (_detailItem != newDetailItem) { _detailItem = newDetailItem; // Update the view. [self configureView]; } if (self.masterPopoverController != nil) { [self.masterPopoverController dismissPopoverAnimated:YES]; } } </code></pre> <p>I also note that the value of detailItem logs "0" as soon as the detailView is loaded, before an indexPath row is selected at all. </p> <p>Im wondering why this property is not being assigned from the MasterViewController, and the TableView is not being updated. </p> <p><strong>EDIT</strong></p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int indexRowTouched = indexPath.row; detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController]; detailViewController.detailItem = indexRowTouched; NSLog(@"index row %i", indexRowTouched); } </code></pre> <p>Trying to access the setDetailItem on the UINavigationController seems to have been fixed by changing the didSelectRowAtIndexPath to the above</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload