title: deleting binary data from Core Data iOS 8
body: <p>I have an app that allows users to download images from a website. (Toy Collector Checklist 2 - <a href="https://itunes.apple.com/us/app/toy-collector-checklist-2/id919363870?mt=8" rel="nofollow">https://itunes.apple.com/us/app/toy-collector-checklist-2/id919363870?mt=8</a>)</p>
  
  <p>The user could theoretically download thousands of images, creating quite a large usage hog. I'm trying to add a "Delete All Images" so a user can flush out the images without deleting the app.</p>
  
  <p>The code seems to work. The images are no longer visible when the button is pressed, and the core data value returns "nil" when I check it - but when I go to my usage settings the space doesn't appear to be freed up. I'm using what I would consider pretty standard fetch and update code:</p>
  
  <pre><code>CoreDataHelper *cdh =
  [(AppDelegate *)[[UIApplication sharedApplication] delegate] cdh];
  
  NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
  NSEntityDescription *entity = [NSEntityDescription
                                 entityForName:@"Item"
                                 inManagedObjectContext:cdh.context];
  [fetchRequest setEntity:entity];
  //   [fetchRequest setPredicate:nil];
  [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"photo != nil OR photoAlt != nil OR photoCam != nil"]];
  [fetchRequest setFetchBatchSize:500];
  NSManagedObject *removePhotoFromObject;
  NSError *error = nil;
  NSArray *results = [cdh.context executeFetchRequest:fetchRequest error:&amp;error];
  for (removePhotoFromObject in results) {
      [removePhotoFromObject setValue:nil forKey:@"photoCam"];
      [removePhotoFromObject setValue:nil forKey:@"photo"];
      [removePhotoFromObject setValue:nil forKey:@"photoAlt"];
      [removePhotoFromObject setValue:nil forKey:@"thumbnail"];
  
  
  
  }
  [cdh backgroundSaveContext];
  </code></pre>
  
  <p>That sets the value of the possible photo locations to nil. If I run the same code again, it doesn't add them into the array (because their values are now nil), so I know that part is working. And the images and thumbnails are removed. But the data usage doesn't change when I check in the Settings tab.</p>
  
  <p>Something that may be mucking up the workings:</p>
  
  <p>Item is an entity.
  photo, photoAlt, and photoCam are ALSO each entities, with a "To One" relationship with Item</p>
  
  <p>They are all attributed as "Binary Data" in the model.</p>
  
  <p>Any thoughts and suggestions would be greatly appreciated. I have looked on these forums, as well as the larger internets, but have so far been unable to find a solution.</p>
  
  <p>Zack</p>