Orphaned images


#1

I think I may have missed something in the book. If we delete a possession from ItemsViewController edit mode, the possession will be released, but that will just release the imageKey. The image is still sitting in the ImageStore and stays there right?

I added a line to tableView:commitEditingStyle:forRowAtIndexPath:(see below)

  • (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    {
    // take care of delete edits
    if (editingStyle == UITableViewCellEditingStyleDelete)
    {

    // remove the image from ImageStore
    if ([p imageKey]) [[ImageStore defaultImageStore] deleteImageForKey:[p imageKey]];

    }
    }

EDIT: I moved this to PossessionStore in my code because chapter 14 has another place where Possessions are deleted.
EDIT: This is addressed in the book in ch 15, also by modifying ImageStore.