使用来自管理对象的集合作为获取结果控制器的数据

| 我想创建一个导航界面,用户可以在其中点击一个单元格,并拥有一个与上一个相同的新导航控制器。我的托管对象具有以下结构:
name (string)
orderId (int)
orderBy (string, a key path indicating what to order the table with)
dateCreated (date)
items (a relationship pointing to the items for the next table)
在点击包含非零项目的项目时,下一个控制器获得对被点击项目的引用,并使用其“项目”,“ orderBy”和“ orderId”来构造获取的结果控制器( (其项目作为数据)和排序描述符(使用orderBy和OrderId)。 如何告诉获取的结果控制器将项目返回的ѭ1用作其数据?我可以使用谓词将结果限制为仅一个对象的项吗?谢谢     
已邀请:
您的商品需要具有反向多对一关系。让我们将该关系称为“父”。 在您的tableView委托的didSelectRowAtIndexPath:中,启动一个新的视图控制器,并将\“ parent \”对象传递给上述indexPath。您将需要创建一个访问器,以将所述对象保存在下一个视图控制器中。 如您所料,您可以做一个谓词,以便您的fetchedResultsController只返回说的“项目”。使获取的结果仅搜索\“ item \”实体。
NSPredicate *resultsPredicate = [NSPredicate predicateWithFormat:@\"parent == %@\", parentObject];
[fetchRequest setPredicate:resultsPredicate];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] 
    initWithKey:[parentObject valueForKey:@\"orderBy\"] ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
基本上,您正在搜索与所选对象有父级关系的所有\“ item \”。 让我知道我是否描述正确(很抱歉,如果我没有这样做,但是我自己做,可以指出一个Apple示例)。 编辑:Apple示例代码 http://developer.apple.com/library/ios/#samplecode/CoreDataBooks/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008405 http://developer.apple.com/library/ios/#samplecode/iPhoneCoreDataRecipes/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008913     

要回复问题请先登录注册