views:

169

answers:

1

Hi there, I have an entity called Pupil, and an entity called Loan. The Pupil entity has the attributes: firstName, lastName, address, postCode, telephoneNumber. The Loan entity has the attribute: loanID, and the relationship: pupilID, which is a relationship to the entity Pupil.

I wish to display the loanID, with the pupil (if any) related to the loanID in a table. e.g.:

LoanID | firstName | lastName | address     | postCode | telephoneNumber
   1   |    bob    |  smith   | 98 Any Road |  N1 1QW  | 0123456789

How would I go about this? I am currently using the bindings for my other tables.

Thank you!

+3  A: 

You can do this assuming that you have set the reverse relationship for pupilID (i.e. a relationship from Pupil to the Loan). If you call that relationship loan, and have an NSArrayController, PupilsController bound to the collection of Pupils, then your first table could be bound to PupilsController.arrangedObjects.loan.loadID and your other columns bound as you'd expect.

On a purely stylistic side note, the pupilID property would more appropriately be named pupil. Core Data is no an ORM and you're not in SQL JOIN land any more. Name the properties what they are, not how they're implemented under the hood by Core Data.

Barry Wark
Thanks for your help! I will change the relationship names around too!
Michael