核心数据:可以NSFetchedResultsController获取两个不同的实体? [英] Core data: can NSFetchedResultsController fetch two different entities?

查看:137
本文介绍了核心数据:可以NSFetchedResultsController获取两个不同的实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个iPhone应用程序,在一个特定的视图,我需要加载两个不同的实体:一个将填充 UITableView ,另一个将填充 UITextView

I am working on an iPhone app, and in a particular view I need to load two different entities: One that will populate a UITableView, and another that will populate a UITextView.

可以使用单个 NSFetchedResultsController

还是我需要使用两个不同的 NSFetchedResultsController s?

Or do I need to use two different NSFetchedResultsControllers?

关于如何最好地解决这个问题的任何想法?

Any ideas on how to best approach this problem?

推荐答案

每个获取请求只有一个实体,控制器只有一个提取。因此,您需要为每个实体单独的控制器。

Each fetch request has only one entity and each fetched results controller has only one fetch. Therefore, you need separate controllers for each entity.

如果你考虑它,你如何使一个谓词获取两个逻辑上独立的实体?

If you think about it, how would you make a predicate to fetch two logically separate entities?

您可能根本不需要两次抓取。在大多数情况下,您可以获取填充表的实体,然后使用所选行的实体的关系来填充类似文本视图的内容。

You probably don't need two fetches at all. In most cases, you can fetch the entities that populate the table and then use a relationship for the entity of the selected row to populate something like a text view.

这篇关于核心数据:可以NSFetchedResultsController获取两个不同的实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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