我有三种类型的自定义类(见下文)和三个数组 componentList、componentGroupList 和 componentGroupItemList。数组没有链接,每个数组都包含所有对象。我需要过滤特定组件、其所有相关组及其所有相关项目。
现在,我知道如何使用 @"componentId==123" 过滤 componentList 并获取所需的组件对象。我还可以使用相同的谓词从 componentGroupList 中过滤其组,因为 ComponentGroup 对象包含相同的 componentId 键。但是,我不知道如何从 componentGroupItemList 中过滤相关的 ComponentGroupItem 对象。
目前,我已经过滤了包含 ComponentGroup 对象的数组,并且我想使用该数组过滤 componentGroupItemList。是否有可能,或者我是否需要从filteredComponentGroupList 中提取所有“groupId”值到一个字符串中,然后做一些谓词?
课程:
@interface Component : NSObject
@property (nonatomic, strong) NSNumber *componentId;
@property (nonatomic, strong) NSString *title;
@end
@interface ComponentGroup : NSObject
@property (nonatomic, strong) NSNumber *groupId;
@property (nonatomic, strong) NSNumber *componentId;
@property (nonatomic, strong) NSString *title;
@end
@interface ComponentGroupItem : NSObject
@property (nonatomic, strong) NSNumber *itemId;
@property (nonatomic, strong) NSNumber *groupId;
@property (nonatomic, strong) NSString *title;
@end