Section Key Path

The sectionNameKeyPath property links a managed object attribute to section names. This property helps determine which section each managed object belongs to. You can set this property directly at any time, or you can initialize it when you set up your fetched results controller.

Recipe 12-1 uses an attribute named section to distinguish sections, although you can use any attribute name for this key path. For this example, this attribute is set to the first character of each object name to assign a managed object to a section. Set the key path to nil to produce a flat table without sections.

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.