I have three types of custom classes (see below) and three arrays componentList, componentGroupList and componentGroupItemList. Arrays are not linked, each of them contain all objects. I need to filter specific component, all its related groups and all their related items.
Now, I know how to filter componentList using @"componentId==123" and get desired component object. I can also filter its groups from componentGroupList using the same predicate, because ComponentGroup object contains the same componentId key. However, I don't know how to filter related ComponentGroupItem objects from componentGroupItemList.
Currently, I have filtered array containing ComponentGroup objects, and I would like to filter componentGroupItemList using that array. Is it possible, or do I need to extract all "groupId" values from filteredComponentGroupList into a string and then make some predicate?
The classes:
@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