0
我已經以下類如何使用NSPredicate過濾另一個類屬性?
EntityOne - Property1 : string - Property2 : int - Property3 : Array of EntityTwo EntityTwo - Property1 : string - Property2 : int
我想要寫一個NSPredicate
其中當我保持EntityOne
對象陣列上執行它EntityTwoObj.property1
過濾。
可能嗎?
我曾嘗試以下操作:
NSPredicate *bPredicate = [NSPredicate predicateWithFormat:
@"Property1 CONTAINS[cd] %@
OR Property2 CONTAINS[cd] %@
OR Property3.Property1 CONTAINS[cd] %@",
newString, newString, newString];
但它不工作。
如果我刪除了最後一個過濾器,那麼它工作正常。
您可能需要一個'ANY'或'IN'作爲最後一個。 – Larme
@Larme,非常感謝你,它的工作原理! :) – Hemang