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!
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 relationshiploan, and have anNSArrayController,PupilsControllerbound to the collection of Pupils, then your first table could be bound toPupilsController.arrangedObjects.loan.loadIDand your other columns bound as you’d expect.On a purely stylistic side note, the
pupilIDproperty would more appropriately be namedpupil. 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.