次のコードは警告を出しましたSending 'ViewController *const __strong' to parameter of incompatible type 'id<AVAudioPlayerDelegate>'
(これは次のコードの3行目です):
NSURL *sound0URL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"0" ofType:@"aiff"]];
audioPlayer0 = [[AVAudioPlayer alloc] initWithContentsOfURL:sound0URL error:nil];
[audioPlayer0 setDelegate: self]; // <--- this line causes the warning
[audioPlayer0 prepareToPlay];
audioPlayer0.currentTime = 0;
[audioPlayer0 play];
どうすれば修正できますか?このコードは、ViewController
のインスタンスメソッドにありviewDidLoad
ます。同様の別の質問がありましたが、それはクラスメソッドでした:「クラス」から「id<AVAudioPlayerDelegate>」に割り当てる互換性のないポインタ型