开发者

Why am I getting an error?

The following line of code compiles with the following w开发者_如何学JAVAarning:

Code:

[[[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error] play];

Warning:

/Users/moshe/Development/iPhone/Apps/Live/iDecide/iDecideViewController.m:29:0 /Users/moshe/Development/iPhone/Apps/Live/iDecide/iDecideViewController.m:29: warning: multiple methods named '-play' found

What's going on here?


(completely new answer)

The init method is returning type id so you are going to get that message as there are multiple methods with that signature within the Cocoa frameworks

Do it in two steps (init then play) and it should vanish.

NSError *error = NULL;
AVAudioPlayer *myplayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if(!error) { [myplayer play]; }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜