NSPredicate with relationship @“SELF。<relationship>。<relationship>。<object> ==%@”</object> </relationship> </relationship>

时间:2012-10-20 22:32:09

标签: core-data nspredicate relationship nsmanagedobject nsfetchedresultscontroller

我有以下NSManagedObjects

Product <<->> ProductAttribute <->> ProductAttributeOption

使用NSPredicate根据产品获取ProductAttributeOption的正确方法是什么?

我没有运气就尝试了以下内容:

[NSPredicate predicateWithFormat:@"ANY SELF.productAttribute.products MATCHES %@", product]

[NSPredicate predicateWithFormat:@"ANY SELF.productAttribute@distinctUnionOfSets.products MATCHES %@"", product]

[NSPredicate predicateWithFormat:@"ANY SELF.productAttribute.@distinctUnionOfSets.giftProducts LIKE[cd] %@", self.giftProduct]

有什么建议吗?谢谢!

1 个答案:

答案 0 :(得分:5)

以下谓词应该有效:

[NSPredicate predicateWithFormat:@"ANY productAttribute.products = %@", product];

“MATCH”和“LIKE”用于匹配字符串的谓词。