gpt4 book ai didi

ios - 具有非唯一部分名称的 NSFetchedResultsController

转载 作者:行者123 更新时间:2023-11-30 12:41:46 26 4
gpt4 key购买 nike

我正在使用以下代码初始化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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com