I'm creating a timeclock application where there is a ClockPunch NSManagedObject model with properties representing a clockin and clockout punch. Each ClockPunch instance has a relationship with an Employee in the Employees model (which also has a one-to-many relationship with each punch). I want to be able to write an NSPredicate that will give me the employee with their most recent clockin punch. I can then determine if they are clockedin or clocked out by whether or not they have a clockout punch to match. I do not want to pull all the punches in and then sort them, cause there could be 1000's for each employee. What should I do?
My Model looks like this
Employees<->>ClockPunches