iOS: Sorting and grouping NSFetchedResultsController

倾然丶 夕夏残阳落幕 提交于 2019-12-08 03:20:30

The key path used as sectionNameKeyPath: argument to the fetched results controller must be the same key that is used in the first sort descriptor or generate the same relative ordering.

The fetched results controller first orders all fetched objects according to the first sort descriptor and then groups the objects into sections according to the sectionNameKeyPath. Therefore using different key paths (as in your case "belongsToMainCategory.position" vs. "belongsToMainCategory.name") does not work. This could even cause a runtime error about "out of order sections".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!