The property is synthesized at the top after the implementation begins. Now we can pass theselected country from the table view to the detail view. ThetableView:didSelectRowAtIndexPath method looks like this
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:
//Get the selected country
NSString *selectedCountry= [listOfItems objectAtIndex:indexPath.row];
//Initialize the detail view controller and display it.
DetailViewController*dvController= [[DetailViewController alloc]
dvController.selectedCountry=selectedCountry;[self.navigationController pushViewController:dvController animated:YES];
We first get the selected country from the array, initialize the detail view controller, set theselected country to the property on the detail view controller and display it.
Setting the accessory view
Run the app and now we are able to select a row in a table view. However, it is not obvious tothe user that a row can be selected to see its detail view. We can add a “accessory view” to thecell which will show up at the right end of the row. The accessory view can be set up intableView:cellForRowAtIndexPathmethod or intableView:accessoryTypeForRowWithIndexPath. We will use the later method to keep our codesimple. This is how the source code changes
The above method returns an enum UITableViewCellAccessoryType and we can return four
values: UITableViewCellAccessoryNone, UITableViewCellAccessoryDisclosureIndicator,UITableViewCellAccessoryDetailDisclosureButton, andUITableViewCellAccessoryCheckmark. You can test the code by returning one of the four values to see how the accessory view looks like. If you return“UITableViewCellAccessoryDetailDisclosureButton” clicking on the button will not doanything, since the cell is not selected but a button is clicked. The SDK does provide a methodwhich gets called when the accessory button is clicked and that is called