Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jean-Bernard

macrumors newbie
Original poster
Jul 27, 2013
1
0
I have 3 entities :Person, Address, Country. The relationship are the follow:

Person -> Address & Address -> Person(to-one)
Address ->Country & Country -> Address(to-one)

In my tableView, I have all the Person present in the database and when I click on one person, I see the firstName and lastName in my UIView but I can retrieve the address of the person and of course the country also.

How can I retrieve the good address for the person "A" and the good address for the person "B"? I have tried setRelationshipKeyPathsForPrefetching: but I don't know exactly how it works. Maybe with an ID? Or other solution....

Can you please help me to find a solution?

Thx
 
Last edited:

ryanrey

macrumors newbie
Jul 30, 2013
2
0
Core Data

I am not entirely sure what you are asking, but I'll give it a shot.

First, fetch your entities in a fetch request, specifying entityForName:mad:"nameOfEntity"

in your entity, add an attribute for a specific id each time you create the entity. (Have a method that does this by implementing a counter)

Before you return the fetch request make a sortDescriptor -setting the attribute as the key.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.