2013-10-05 80 views
0

的錯誤想出了[MPC [ALLOC的MPMoviePlayerController]] [[initWithContentURL:URL]]];它說initWithContentURL是一個未聲明的標識符。我如何解決這個問題?使用未申報indentifier

進口 「ViewController.h」

@interface ViewController() 
{ 
    MPMoviePlayerController *mpc; 
} 

@end 

@implementation ViewController 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (IBAction)playButton:(id)sender { 
    NSString *stringpath;[[NSBundle mainBundle]pathForResource:@"Lake Weekend September 13-14" ofType:@"m4v"]; 
    NSURL *url = [[[NSURL fileURLWithPath:stringpath] 
    [mpc [[MPMoviePlayerController alloc]][[initWithContentURL:url]]]; 
    [mpc setMovieSourceType:MPMovieSourceTypeFile]; 

    [[self view ]addSubview:mpc.view]; 

    [mpc setFullscreen:YES]; 

    [mpc play]; 
} 
@end 
+0

你在這個指令的最後缺少一個分號(終結者)「NSURL * URL = [[[NSURL fileURLWithPath:stringpath]」 –

回答

0

你還沒有使用它之前聲明的網址?你想它的聲明中使用它...

NSURL *url = [[[NSURL fileURLWithPath:stringpath] 
[mpc [[MPMoviePlayerController alloc]][[initWithContentURL:url]]]; 

你至少應該有第一線後分號..然後你就可以使用URL。另外你需要整理你的附加支架,試試這個..

NSURL *url = [NSURL fileURLWithPath:stringpath]; 
mpc = [[MPMoviePlayerController alloc]initWithContentURL:url]; 
+0

如何,我宣佈它? – Nick

+0

NSURL * url = [[[[NSURL fileURLWithPath:stringpath]; [mpc [[MPMoviePlayerController alloc]] [[initWithContentURL:url]]]; //注意分號.. –

0

你的alloc/init的mpc看起來都是錯的。這條線看起來都是亂碼給我的。我認爲,該行應改爲類似:

mpc=[[MPMoviePlayerController alloc] initWithContentURL: url];