2013-01-17 38 views
-1
-(void)playSound: (NSString*)sound 

{ 
NSString *path = [[NSBundle mainBundle] pathForResource:sound ofType:@"mp3"]; 

    AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; 
theAudio.delegate = self; 
    [theAudio play]; 
    [AVAudioPlayer release]; 
} 

一切仍然有效,只是一個令人討厭的錯誤,可能會導致滯後。我得到錯誤,「從不兼容的類型」gameViewController「分配給'id avaudioplayerdelegate'」

+1

你的問題是什麼? – Jason

回答

1

一定gameViewController符合AVAudioPlayerDelegate協議:

@interface gameViewController : NSObject <AVAudioPlayerDelegate> 
. 
. 
. 
@end 

假設這是你的類的名稱。

+0

謝謝。我是編碼新手。我是否將它放在標題或實現文件中? –

+0

這應該在你的頭文件中。 – trudyscousin

+0

對不起,我不是故意惹你的頭。 – trudyscousin

相關問題