views:

33

answers:

0

I have a Core Data model with Items and Tags. Items may have multiple Tags, and Tags may be related to multiple Items. If I have an Item object, it has a tags attribute. Each Tag has a type, indicating that is a user tag, or a system generated tag. What I would like to do is create a fetched property on Item that would return only the user generated tags, and not all of the Tags related to that Item. In the Core Data object graph, I add a fetched property on Items called userTags, and add a predicate like this:

ANY tags.type == 0

Where "0" is the number I use for user tags. However, this code crashes every time I get an Item's userTags. I successfully worked around this with some trivial code:

- (NSSet*) getUserTags {
  return [NSSet filteredSetUsingPredicate:[NSPredicate predicateWithFormat:@"type == 0"]];
}

So my question is more academic: why didn't my first Predicate work in the Core Data modeling?

Thanks,
-dan