我是新手。我正嘗試從數組中調用視頻。我知道我正在將字符串與對象混合。但我不知道用什麼來代替它。這是不正確的代碼行:發送'NSArray'到類型爲'NSString'的參數的指針類型不兼容
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;
}
取決於你想要什麼?數組中的0 1 2 3 4 ..n對象? –
NSString _is_是一個對象。你在混合類型。該錯誤告訴你該參數需要一個NSString,但代碼傳遞一個NSArray。我建議對Objective-C有更好的,基本的瞭解,並尋找這個常見的錯誤。在使用pathForRes的SO上必須有數百個例子。 – Anna
我知道這是錯的。我不知道如何解決它。我正嘗試根據用戶在表單元格中點擊的內容設置視頻。所以,如果用戶點擊單元格2,他們會得到視頻2(數組中的#1)。 – CharleyB