Just pass the Doctor
object obtained when the user tapped the cell to your detail controller. Then in the detail controller use doctor.patients
(the NSSet). This is the simplest option and will work well if you aren't making any changes to the data. You're probably displaying the patients in a table view so you will want to use NSSortDescriptor
to organise the patients before displaying them (then they will be in an array and you use objectAtIndex:
).
If you're going to change the data it'll still work, but you need to know about the change in some way so you can update the UI.
If you already have a fetched results controller, that's fine and will monitor changes for you. In that case use the doctor
in the predicate format:
[NSPredicate predicateWithFormat:@"doctor = %@", self.doctor];
Either way, pass the doctor object to the new view controller.