Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-19-2011, 12:07 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 4
Xintare is on a distinguished road
Default FetchRequest: Select distinct and non-distinct properties

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!
Xintare is offline   Reply With Quote
Reply

Bookmarks

Tags
core data, fetchedresultscontroller, iphone

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 357
11 members and 346 guests
7twenty7, dre, iAppDeveloper, jeroenkeij, Mah6447, Morrisone, mottdog, sacha1996, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:41 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0