• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSPredicate complex groups
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPredicate complex groups


  • Subject: NSPredicate complex groups
  • From: Arved von Brasch <email@hidden>
  • Date: Wed, 31 May 2006 01:33:14 +1000

Greetings Cocoa Dev List,

I have three CoreData Entities in relationships. The relationship is named 'keywords' on one side and 'articles' on the other. The keyword entity has an attribute 'name'. Articles are in a standard parent - children relationship with themselves for use in a NSTreeController. I have a list of article groups, and want to find out if any of each groups children has a keyword with a particular name.

To illustrate:

ArticleGroup <-parent--children--> Article <<-articles--keywords->> Keyword

I know the keyword name I'm searching for, and have a list of ArticleGroups, how can I construct a Predicate to filter the ArticleGroups to only include those groups that have Articles with the keyword name of interest?

I have tried the obvious:  ANY children.keywords.name == %@

The documentation on using predicates doesn't explicitly state that this is even possible, and I fear it might not be.

If that is the case, then I had another thought about how to solve this problem. Articles have ArticleGroups as their parent entity. keywords is actually a relationship attribute for ArticleGroups, but is always the empty set for ArticleGroups. Is there a nice way to have each ArticleGroup return an amalgamation of their children's keywords?

That is, suppose 'Solar' is an ArticleGroup with two Articles; 'ANU', 'UNSW'. ANU had keywords with name attributes 'photovoltaic' and 'university', and UNSW had keywords 'university' and 'thermal'. Then Solar's returned keywords would be 'university', 'photovoltaic' and 'thermal'.

This would be easy if the keyword relationship were 1-to-many, as it is easy to provide a custom accessor method for to-1 relationships. The documentation implies that the only supported accessor method for to-many relationships is mutableValueForKey: or valueForKey: neither of which I particular want to override in ArticleGroup as I'd have to undo the override for the child entity Article.

Any thoughts?

Cheers and thanks in advance,

Arved von Brasch
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Creating complex arrays & dictionaries
  • Next by Date: Re: Re: DIsplaying non-english characters
  • Previous by thread: Creating complex arrays & dictionaries
  • Next by thread: Changing from Java to OBJ-C
  • Index(es):
    • Date
    • Thread