title: How to retrieve a specific object through a relationship in core data
body: <p>Say I have 2 managed objects in my model: <code>Department</code> and <code>Employee</code> (as discussed in the <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOs.html#//apple_ref/doc/uid/TP40001803-SW3" rel="nofollow">Core Data Programming Guide</a>).  If I already have a specific department retrieved, I know I can get all employees in that department through</p>
  
  <pre><code>NSSet *departmentsEmployees = aDepartment.employees;
  </code></pre>
  
  <p>but what if I want to find a specific employee (e.g. with employeeId = 123) in that set, change one of its attributes, then save the change?  How do I do that?  Can I do a targeted query on the set?  Or would I have to loop through each employee to find the one I want?</p>
  
  <p>It seems that it would be better to try to find it in the <code>employees</code> NSSet instead of doing a whole new query to the entire data model because I already have a specific department.</p>
  
  <p>Thank you</p>