How to solve the warning: Sending 'ViewController *const __strong' to parameter of incompatible type 'id<AVAudioPlayerDelegate>?

Conform to the AVAudioPlayerDelegate protocol in your header file and the warning will go away. By not declaring that a class conforms to a given protocol, the compiler cannot guarantee (well, at least warn) about your failure to implement the methods required of it. The following code is a corrected version that will suppress the warning.

@interface ViewController : UIViewController <AVAudioPlayerDelegate>
@end

Interestingly that didn't do it for me. I have the delegate defined in header file - working with UIImagePickerControllerDelegate in a UITableViewController. Since setDelegate method expected an id, I set delegate as follows instead:

[myImagePicker setDelegate: (id)self];

But I would like to know what's happening here ? Since this is not normally showing itself in other delegate examples in other areas of code. Could anyone elucidate on this ?

Thanks


Your self (your class) doesnt have the

@interface MyClassName: NSObject <AVAudioPlayerDelegate>

in the header file.