Section Headers

Sorting is a good first step, though it is still difficult to find where each new car make begins and ends. This is a good place to use table sections and headers. The best way to think of a section is as a group of related data. In the contacts list, groups are based on the first letter of the last name (or first name, if that’s what is set in the Settings app). In your app, all Chevrolets would be in one section, and all Mercedes would be in another.

In tables using a fetched results controller, you need to take only a few steps to show section headers. You already have a table sorted on make, so follow these steps to add the section headers:

1. Open CarTableViewController.m and go to viewDidLoad.

2. In the statement that allocates ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming 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.