Creating a Section Index

Tables that implement sectionIndexTitlesForTableView: present the kind of index view that appears on the right in Figure 9-6. This method is called when the table view is created, and the array that is returned determines what items are displayed onscreen. Return nil to skip an index. Apple recommends adding section indexes only to plain table views—that is, table views created using the default plain style of UITableViewStylePlain and not grouped tables:

// Return an array of section titles for index - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)aTableView {     NSMutableArray *indices = [NSMutableArray array];     for (int i = 0; i < crayons.numberOfSections; i++)     {         NSString ...

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.