Delegation with Sections

As with data source methods, the trick to implementing delegate methods in a sectioned table involves using the index path section and row properties. These properties provide the double access needed to find the correct section array and then the item within that array for this example:

// On selecting a row, update the navigation bar tint - (void)tableView:(UITableView *)aTableView     didSelectRowAtIndexPath:(NSIndexPath *)indexPath {     UIColor *color = [crayons colorAtIndexPath:indexPath];     self.navigationController.navigationBar.barTintColor = color; }

Recipe 9-4 Supporting a Table with Sections

/* CrayonHandler.m */ // Return an array of items that ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.