NSInvalidArgumentException - 当我尝试将捕获的视频复制到文档文件夹时,应用程序终止

时间:2010-05-16 16:47:12

标签: iphone uiimagepickercontroller video-processing

我想尝试群众的智慧......因为我现在很沮丧。 提前谢谢。

所以这是我的代码:

- (void)imagePickerController:(UIImagePickerController *)ipc didFinishPickingMediaWithInfo:(NSDictionary *)info{

NSLog(@“info:%@”,info);

NSString * newFilename = [NSString stringWithFormat:@“%@ /%@。mov”,         [NSHomeDirectory()stringByAppendingPathComponent:@“Documents”],         [NSString stringWithFormat:@“%d”,(long)[[NSDate date] timeIntervalSince1970]]];

NSLog(@“newFilename:%@”,newFilename);

NSFileManager * filemgr = [NSFileManager defaultManager];

NSError *错误;   if([filemgr copyItemAtPath:[info objectForKey:@“UIImagePickerControllerMediaURL”] toPath:newFilename error:& err] == YES)         NSLog(@“移动成功”);  其他         NSLog(@“移动失败”);

这是日志:

 2010-05-16 18:19:01.975 erlkoenig[7099:307] info: {
    UIImagePickerControllerMediaType = "public.movie";
    UIImagePickerControllerMediaURL = "file://localhost/private/var/mobile/Applications/BE25F9B5-2D08-4B59-8B62-D04DF7BB7E5B/tmp/-Tmp-/capture-T0x108cb0.tmp.8M81HU/capturedvideo.MOV";
   }
newFilename: /var/mobile/Applications/BE25F9B5-2D08-4B59-8B62-D04DF7BB7E5B/Documents/1274026741.mov

[NSURL fileSystemRepresentation]: unrecognized selector sent to instance 0x1c1f90
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURL fileSystemRepresentation]: unrecognized selector sent to instance 0x1c1f90

1 个答案:

答案 0 :(得分:0)

我可以按照您的逻辑,但有一个基本问题:这不是您保存视频的方式

如果没有相关的错误检查,请参阅下面的粗略示例。

(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

    .... code here .....

    NSString* videoURL= [info objectForKey:UIImagePickerControllerMediaURL];

    //remember to test that the video is compatible for saving to the photos album

    UISaveVideoAtPathToSavedPhotosAlbum(videoURL, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);

    .... code here .....

}