title: Core Data NSBatchDeleteRequest appears to leave objects in context
body: <p>I have seen many questions regarding batch deletion in Core Data, but none seem to address my issue.</p>
  
  <p>I am creating an iOS 9 / Swift app using Core Data. At WWDC this year, I attended the Core Data session and saw that I could use <code>NSBatchDeleteRequest</code> to delete large numbers of objects directly from the persistent store. This works for me for some objects but not others, and I think it has something to do with my relationships.</p>
  
  <p>I have an object graph consisting of <code>Subject</code> and <code>Course</code>, where there is a one-to-many relationship. Subjects may own as many courses as they wish.</p>
  
  <p>There is a 'courses' relationship on <code>Subject</code> with a delete rule of <code>Cascade</code>, as I want all courses associated with a <code>subject</code> to be deleted when a <code>subject</code> is deleted.</p>
  
  <p>The inverse is 'subject' on <code>Course</code>, with a delete rule of <code>Nullify</code>. Here, I am a bit confused as to Apple's description of <code>Nullify</code>:</p>
  
  <blockquote>
    <p>Remove the relationship between the objects but do not delete either object.
    This only makes sense if the department relationship for an employee is optional, or if you ensure that you set a new department for each of the employees before the next save operation.</p>
  </blockquote>
  
  <p>That makes it pretty clear, but why would the relationships be deleted but not either object? If I delete a <code>Course</code>, I would like the <code>Course</code> to be deleted and the relationship from the <code>subject</code> to the <code>course</code> to be deleted so that a fault to the deleted <code>Course</code> will not appear in the <code>NSSet</code> on <code>Subject</code>'s <code>courses</code> Set.</p>
  
  <p>I want to provide a way for all objects in an entity to be deleted. When I try this by individually fetching and deleting each <code>course</code>, <code>courses</code> are properly deleted and removed from the <code>NSSet</code> of <code>courses</code> on a <code>Subject</code>.</p>
  
  <p>Since I have no idea how many <code>courses</code> will be present and I want to ensure high performance in every situation, I figured I would use batch deletion to delete all <code>courses</code>. The problem is that while utilizing <code>NSBatchDeleteRequest</code> to delete all <code>Subjects</code> works fine, deleting all <code>courses</code> along the way (because of the <code>Cascade</code> rule), trying to delete all <code>Courses</code> using this method appears to leave all objects in place.</p>
  
  <p>I used <code>NSBatchDeleteRequest</code> to delete all <code>Courses</code>, but then when I query the <code>MOC</code> to see what <code>Subjects</code> and <code>Courses</code> still exist, both <code>Courses</code> are still returned and the <code>Subject</code> owning them still has references to them.</p>
  
  <p>In contrast, when I fetch and delete each <code>Course</code> individually, my subsequent fetch properly displays an empty array for all <code>Courses</code> and the 'courses' relationship on the <code>Subject</code> appears to have been properly modified.</p>
  
  <p>Yes, I am saving the context after executing the request. I suppose the context may not be notified of what the store does, but then again deleting all <code>subjects</code> worked great. What is going on here?</p>