ฉันมีคลาสแบบกำหนดเองสามประเภท (ดูด้านล่าง) และสามอาร์เรย์componentList,componentGroupListและcomponentGroupItemList อาร์เรย์ไม่ได้เชื่อมโยง แต่ละอาร์เรย์มีออบเจ็กต์ทั้งหมด ฉันต้องกรองส่วนประกอบเฉพาะ กลุ่มที่เกี่ยวข้องทั้งหมด และรายการที่เกี่ยวข้องทั้งหมด
ตอนนี้ฉันรู้วิธีกรองส่วนประกอบรายการโดยใช้ @"componentId==123" และรับวัตถุส่วนประกอบที่ต้องการ ฉันยังสามารถกรองกลุ่มจาก ComponentGroupList โดยใช้เพรดิเคตเดียวกันได้ เนื่องจากออบเจ็กต์ ComponentGroup มีคีย์ ComponentId เดียวกัน อย่างไรก็ตาม ฉันไม่รู้วิธีกรองออบเจ็กต์ ComponentGroupItem ที่เกี่ยวข้องจาก ComponentGroupItemList
ขณะนี้ ฉันได้กรองอาร์เรย์ที่มีออบเจ็กต์ ComponentGroup แล้ว และฉันต้องการกรองส่วนประกอบGroupItemList โดยใช้อาร์เรย์นั้น เป็นไปได้หรือฉันต้องแยกค่า "groupId" ทั้งหมดจาก filteredComponentGroupList ลงในสตริงแล้วสร้างเพรดิเคต
ชั้นเรียน:
@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