[英]Files Deleting from Table View but not from Document Directory by using Swipe Gesture
if (editingStyle == UITableViewCellEditingStyleDelete){
NSFileManager *fileManager = [[NSFileManager alloc]init];
NSString *filePath = [documentsDirectory
stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ ",[self->localSongs objectAtIndex:indexPath.row]]];
[fileManager removeItemAtPath:filePath error:nil];
[self->localSongs removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView reloadData];
}
有什么建議嗎?
以下是有關如何從文檔目錄中刪除文件的代碼:
NSString *imageName = @"name of your file"
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
[fileManager removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:imageName] error:nil];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.