Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何让fetchedResultsController根据从以前的视图控制器中的另一个FRC检索的对象为我的TableView提供数据?_Ios_Objective C_Nsfetchedresultscontroller - Fatal编程技术网

Ios 如何让fetchedResultsController根据从以前的视图控制器中的另一个FRC检索的对象为我的TableView提供数据?

Ios 如何让fetchedResultsController根据从以前的视图控制器中的另一个FRC检索的对象为我的TableView提供数据?,ios,objective-c,nsfetchedresultscontroller,Ios,Objective C,Nsfetchedresultscontroller,这是我的结构: 我有一个叫做元素的实体。元素包含多个时间戳。时间戳是与元素有关系的实体 Element Time Stamp 1 Time Stamp 2 Time Stamp 3, ..., ... 我的视图控制器和表视图是: View Controller A TableView A // <- displays elements View Controller B TableView B // <- should display a

这是我的结构:

我有一个叫做元素的实体。元素包含多个时间戳。时间戳是与元素有关系的实体

Element
   Time Stamp 1
   Time Stamp 2
   Time Stamp 3,
   ...,
   ...
我的视图控制器和表视图是:

View Controller A
   TableView A // <- displays elements

View Controller B
   TableView B // <- should display all timestamps from a given element
现在,在我的视图控制器B上有一个fetchedResultsController,它为我的表视图B提供数据。我需要这个fetchedResultsController显示传递的元素对象的所有时间戳

我该怎么做

我知道我可以通过向元素添加一个唯一的日期属性来解决这个问题,这样我就可以在视图控制器B中有一个匹配该唯一日期的谓词。然而,如果可能的话,我宁愿不这样做。我发现很难相信我需要有我的核心数据实体来依赖于我需要在视图控制器中执行的操作


谢谢大家!

如果时间戳是NSSet,您可以将其传递给ViewController B,并删除B中的fetchedResultsController


或者,不要像上面那样分配实体,而是将NSManagedObjectID传递给ViewController B,并基于它执行提取。如果您想在B中使用fetch控制器,这将是一种更好的方法。

您应该能够使用fetchedResultsController使用以下谓词来获取时间戳对象


[NSPredicate predicateWithFormat:@“element==%@”,self.element]

时间戳是一个实体,与元素有关系?是的,@Wain,它是!=)我将更新问题。然后@Cleverror提供了您的答案
Element *anElement = [_fetchedResultsController objectAtIndexPath:indexPath];

ViewControllerB *vc = (ViewControllerB *)[[self storyboard]instantiateViewControllerWithIdentifier:@"ViewControllerB"];
vc.element = anElement;