0

I have the following NSManagedObjects:

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

What's the correct way for using an NSPredicate to fetch the ProductAttributeOptions based on the product?

I've tried the following without luck:

[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]

Any advice? Thanks!


The following predicate should work:

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

"MATCH" and "LIKE" are used in predicates for matching strings.

4

1 回答 1

5

以下谓词应该起作用:

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

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

于 2012-10-21T09:52:13.593 回答