简体   繁体   English

核心数据:从3个实体中提取对象到一个实体中并按日期排序?

[英]Core-Data: Fetch objects from 3 entities into one fetch and sort by date?

I could use some help breaking down this puzzle. 我可以使用一些帮助来解决这个难题。

1) I want to fetch objects from 3 entities ('A','B','C') in Core-Data (they all have different data types, except 'date') - have them in one big fetch, somehow? 1)我想从Core-Data中的3个实体('A','B','C')中获取对象(它们都具有不同的数据类型,但'date'除外)-以某种方式将它们一次大地获取? Should they have relations to a new entity 'D' or? 他们应该与新实体“ D”有关系吗?

2) Later, I want to sort the big fetch by date (but I dont think it's an issue for me if I have the whole fetch). 2)以后,我想按日期对大访存进行排序(但是,如果我拥有全部访存,对我来说这不是问题)。

So if any can help me pointing out 1), I would really appreciate it. 因此,如果有什么可以帮助我指出1),我将不胜感激。

Here is a simple approach, easy to verify and - if needed - debug: 这是一种简单的方法,易于验证,并在需要时进行调试:

  1. Do 3 distinct fetches, one from each entity. 执行3个不同的访存,每个实体一个。
  2. Add the results to an array. 将结果添加到数组。
  3. Sort the array by date. 按日期对数组进行排序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM