Hi there,
I have two Core Data entities for my sqlite-database. One for locations:
Locations
Code:
| locationID | locationName | countryCode |
| 292239 | Berlin | de |
| 291074 | Paris | fr |
| 295522 | Orlando | us |
| 292345 | Tokyo | jp |
There is also a one-to-many relationship with a "AlternateName" entity:
AlternateName:
Code:
| searchName | displayName
| Berlino | Berlinó
| Berlina | Berlinà
| capital | capitall
| Parisa | Paŕsa
| Pariso | Paríso
| Orlandola | Orlandolá
| Orlandolo | Orlandoḷ
The "AlternateName" entity has a backwards one-to-one relationship to a "Location".
My predicate takes a searchTerm and looks at the "searchName" for every "AlternateName". I would like to get only ONE "AlternateName" per location.
I can take my fetchRequest and set it to returnsDistinctResults only. Then I would have to include "location" (the backwards relation objectID) into my propertiesToFetch. Also, the resultType will have to be a NSDictionary in order for the distinct results to work.
My problem is: Having this configuration, how do I read the "displayName" of my results? I can't include it in the propertiesToFetch, because then, I will get ALL the "alternateNames" for a location. If distinctResults wouldn't limit you to a NSDictionaryResultType, things would be easier.
I hope I made myself clear...
Any ideas? The data could be preprocessed again. Thanks in advance!