title: Delete an image in NSDocumentDirectory
body: <p>I have a custom library that can pick mulitple images from the camera roll, I save my images in the <code>NSDocumentDirectory</code> like this:</p>
  
  <pre><code>         for (int i = 0; i &lt; info.count; i++) {
              NSLog(@"%@", [info objectAtIndex:i]);
              NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory,    NSUserDomainMask ,YES );
              NSString *documentsDir = [paths objectAtIndex:0];
              NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"Images%d.png", i]];
              ALAssetRepresentation *rep = [[info objectAtIndex: i] defaultRepresentation];
              UIImage *image = [UIImage imageWithCGImage:[rep fullResolutionImage]];
              //----resize the images
              image = [self imageByScalingAndCroppingForSize:image toSize:CGSizeMake(256,256*image.size.height/image.size.width)];
  
              NSData *imageData = UIImagePNGRepresentation(image);
              [imageData writeToFile:savedImagePath atomically:YES];
  
              NSLog(@"saving at:%@",savedImagePath);
  
          }
  </code></pre>
  
  <p>What I wanted to do is I wanted to load it in a thumbnail with <code>UIScrollView</code> then when a specific picture is tapped a <code>AlertView</code> will popup,will ask the user if it wants to delete it. I manage to make it load in a thumbnail view (I use the<code>HSImageSidebarView</code>) and make the <code>AlertVIew</code> popups whenever a user taps in a image. But when I press delete it deletes in the view but not in the <code>NSDocumentDirectory</code>. </p>
  
  <p>This is how I delete my image:</p>
  
  <pre><code>- (void)sidebar:(HSImageSidebarView *)sidebar didRemoveImageAtIndex:(NSUInteger)anIndex {
      NSLog(@"Image at index %d removed", anIndex);
      [images removeObjectAtIndex:anIndex];
  
      NSFileManager *fileManager = [NSFileManager defaultManager];
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
      NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"Images%d.png", anIndex]];
      [fileManager removeItemAtPath: fullPath error:NULL];
      NSLog(@"image removed");
  }
  </code></pre>