开发者

NSFetchedResultsController and UITableView Sections

开发者 https://www.devze.com 2023-01-11 13:03 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号