作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用以下代码初始化NSFetchedResultsController
self.fetchedResultsController = NSFetchedResultsController(
fetchRequest: request,
managedObjectContext: context,
sectionNameKeyPath: "article.name",cacheName: nil
)
这里的文章可以具有相同的名称。因此 article.name
sectionNameKeyPath
不是唯一的。在这种情况下,fetchedResultsController
将只有单个部分。
如何处理具有相同部分名称的多个部分?
最佳答案
对于sectionKeyPath,返回该部分的UUID(article.articleId 等)。然后,当您在节中显示标题的标题时,不要显示从 fetchedResultsController (self.fetchedResultsController.sections[section].name
) 返回的名称,而是获取该节中的第一个对象并根据该值找出您真正想要显示的内容 (self.fetchedResultsController.sections[section].objects.firstObject.article.name
)。
关于ios - 具有非唯一部分名称的 NSFetchedResultsController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42153108/
我是一名优秀的程序员,十分优秀!