I use an NSFetchedResultsController
to populate a UITableView
, and would like to know if it is possible to create different sections based on an attribute of my data model.
I am displaying a table of objects, and one of the propert开发者_开发问答ies of the objects is a BOOL that is set to indicate whether or not the object is active. I would like to break the records apart in the UITableView
and have section one display the objects with Active==YES and the second section display objects that are not active.
How is this done?
You set the sectionNameKeyPath:
of the NSFetchedResultController initialization method to the name of the attribute you want to use for the sections. The FRC returns a section for each unique value of that attribute.
精彩评论