Sorry if this is a stupid question, but I have come across a problem when setting the delegate property of an AVAudioPlayer instance.
In my program, I create 4 AVAudioPlayer instances. These are all in a class called ShapeView, derived from NSObject. I am not sure exactly what I am supposed to set the delegate to, and when I set it to ‘self’ it gives me the warning: “Sending ‘ShapeView *const_strong to parameter of incompatible type ‘id'”
I am a relatively inexperienced programmer playing around with sounds, so any help would be aprreciated.
Thanks!
Two ways to fix this:
1: conform to the protocol in the .h like so:
@interface MyExampleClass : NSObject <AVAudioPlayerDelegate>…Then set the delegate for each one of the players.
2: If the compiler still complains, for some reason casting the self class to id makes it go away. So:
[self.audioplayer setDelegate:(id)self];