Core data relationships from plist data
I have what is probably a very simple problem. My app loads data from two plists into core data (the plists are arrays of dictionaries). One Core Data entity is Person, the other entity is address. The relationship is to-one from person to address and to-many from address to person. In the plists, each person and address has a unique id and I have a key for each person that indicates the address its associated with.
My confusion is how to create this relationship as I load the data. Currently, my program loads all the addresses into coredata and then loads all the persons. I need to be able to point each person to the there associated address. Can someone point me in the right direction for what to do?
It seems like if I try to create both the address and person at the same time I'll be double creating some addresses (e.g. if person a & b live at address 1, I don't want to end up with two address 1s, I want both person a & b to the same address 1). I'm guessing that I need to create the addresses, then fetch them back so when I create each person I can associate it with the already created address. But I'm at a loss for how to do so.
Any guidance would be appreciated.
|