ResultsController 到另一个 ResultsController [英] ResultsController to another ResultsController

查看:14
本文介绍了ResultsController 到另一个 ResultsController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CoreData 和 ResultsController 使工作变得非常简单.但是...

CoreData and ResultsController make the job really easy. But...

情况如下:

我在一个 tableView 中有一个功能 resultsController.选择一行时,我会转到另一个将显示子实体的 tableView.有了 coreData,子实体就可以使用了.但是我如何用这个子实体启动另一个 resultsController 呢?我是否需要再次为这个新的 resultsController 使用谓词进行 fetchRequest 过滤?

I have a functional resultsController in one tableView. When selecting a row, I go to another tableView that will show the child entity. With coreData, the child entity is ready to use. But how do I start another resultsController with this child entity? Do I need to fetchRequest again for this new resultsController using predicate to filter?

父 TablewView:在 resultsController 上选择行-> 子表视图:从接收到的实体初始化并初始化另一个 resultsController-> 子表视图的描述:显示在第二个 RC 上选择的行的详细信息.

Parent TablewView: Select row on resultsController -> Child TableView: init from entity received and init another resultsController -> Desc of Child TableView: show detail from the row selected on the second RC.

有没有更好的方法?

推荐答案

如果你的第二个 UITableView 只是呈现 1 个 NSManagedObject 的细节,为什么要创建一个 resultsController.将指向 NSManagedObject 的指针传递给新的 TableView 并处理它在 UITableViewDataSource 中的显示 协议方法.
您可能希望为 NSArray 中的每一行排序所需的元素,以实现更短的 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 实现.
NSArray 必须在 TableView 首次尝试显示自身之前完成.

If your second UITableView is just presenting the detail of 1 NSManagedObject, why create a resultsController. Pass a pointer to the NSManagedObject to the new TableView and handle it's displaying in the UITableViewDataSource protocol method.
You may want to order the element you want for each row in a NSArray, for shorter - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath implementation.
The NSArray must be done before the TableView first try to display itself.

这篇关于ResultsController 到另一个 ResultsController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆