gpt4 book ai didi

ios - UITableView 中带有 NSFetchedResultsController 的附加部分

转载 作者:行者123 更新时间:2023-11-30 11:05:52 24 4
gpt4 key购买 nike

我目前正在使用 NSFetchedResultsController 实现 UITableViewController。它从 CoreData 中获取一些对象,并按预期将它们显示为一个部分中的行。

现在,我想要一个额外的部分,其中只有一行显示有关所获取对象的聚合信息。

据我所知,一个 NSFetchedResultsController 只能有一个获取请求,但我必须使用另一个请求来获取聚合信息。

也许我应该为整体部分使用一个 NSFetchedResultsController,为单个对象部分使用另一个 NSFetchedResultsController,但这对我来说有点奇怪。

你觉得怎么样?

最佳答案

您可以考虑使用一个 fetchedResultController。并在fetchedResultController的委托(delegate)中添加一些观察者函数:

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller{
[self updateAggregatedInformation : basedOnFecthedObjects]; //with collection keypath methods;
[self updateTableView];

}

tableView 数据源有一点开销,但性能有所提高。

关于ios - UITableView 中带有 NSFetchedResultsController 的附加部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52737811/

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