不兼容的指针类型将'NSArray'发送到'NSString'类型的参数

时间:2013-11-24 20:24:50

标签: objective-c nsstring nsarray

我是新手。我正在尝试从阵列中调用视频。我知道我正在将字符串与对象混合。但我不知道该替换它。这是[错误的]代码行:

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: _arrayVidSrc ofType:@".mp4" inDirectory:@"videos"]];

我该如何解决?

这是整个代码块:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.titlelabel.text = self.titlecontents;
    self.navBar.title = self.titlecontents;


    //video load from array
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: _arrayVidSrc ofType:@".mp4"]];

    MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
    [self presentMoviePlayerViewControllerAnimated:playercontroller];
    playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
    [playercontroller.moviePlayer play];
    playercontroller = nil;


}

1 个答案:

答案 0 :(得分:2)

从上下文中我想你想获得视频的URL数组。如果_arrrayVidSrc是一个数组,则只应传递其中一个元素(例如,在不正确的代码行中尝试使用_arrayVidSrc[0]):

NSString * firstVideoFileName = _arrayVidSrc[0];
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:firstVideoFileName
                                                                    ofType:@".mp4"]];