从文档目录中删除video的问题
我正试图从文档目录中删除一个video,但video并未被删除。
以下是我如何删除video:
//Delete Video NSError *error = nil; //NSData *videoData = [NSData dataWithContentsOfURL:self.finalURL]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/vid1.mp4"]; [[NSFileManager defaultManager] removeItemAtPath: tempPath error: &error]; UIAlertView *removeSuccessFulAlert=[[UIAlertView alloc]initWithTitle:@"Congratulation:" message:@"Successfully removed" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; [removeSuccessFulAlert show];
如果你在你的“ removeItemAtPath
”之后加上一行,你可能会得到一个很好的提示:
BOOL success = [[NSFileManager defaultManager] removeItemAtPath: tempPath error: &error]; if(!success) { NSLog(@"error from removing item at path %@ is %@", tempPath, [error localizedDescription]); } else { UIAlertView *removeSuccessFulAlert=[[UIAlertView alloc]initWithTitle:@"Congratulation:" message:@"Successfully removed" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; [removeSuccessFulAlert show]; }
试试这个:
NSString *tempPath = [documentsDirectory stringByAppendingPathComponent:@"vid1.mp4"];
- ABRecordID是识别唯一联系人的可靠方法吗?
- 禁用具有特定标记的UIButton
- LinkedIn邀请API错误401 -iPhone sdk
- 从xib文件加载ViewController
- “在xCode 5.1中没有select器”validSuits“错误的已知类方法
- 使用AVCaptureVideoDataOutput和AVCaptureAudioDataOutput时的性能问题
- iOS:lldb EXC_BAD_ACCESS自定义单元格
- 在Objective-C中使用偏移量和使用子string获取NSString中字符的索引
- 如何打印出(NSLog)添加到NSMutableArray的自定义对象的属性