I am trying to delete file from the document directory by use of commitEditingStyle
method but I am facing following problem:
In a table I am displaying all file names which are saved in the document directory. As users press "Edit" all cells are activated for Deletion and now if users press on the red button and Delete all files plus Document directory delete, it should delete one file at a time not all with directory. Following is the code:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSMutableString *File = [documentsDirectoryPath stringByAppendingPathComponent:fileNameString];
NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:File error:NULL];
[self.downList removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
}
}
I hope some one knows where is the problem.