I'm trying to write my first iPhone app and i'm having some trouble with a delegate.
I have a class that utilises the AVAudioPlayer to play some sound, I then have another class that I need to do something when that sound is complete. So I need this class to implement audioPlayerDidFinishPlaying method of the audio player.
The problem is, I can't work out how to make my second class a delegate of the audio player that is a member of the first class. I created a method in the first class that takes a reference to a class and runs the setDelegate method on this, but the audioPlayerDidFinishPlaying method never gets called. However if I implement the audioPlayerDidFinishPlaying method in the first class, it gets called fine. How can I get audioPlayerDidFinishPlaying to be called in the second class?
So, the code I'm using to add the delegate, in the first class I have this method:
-(void) setAudioDelegate:(id)delegate{
[audioPlayer setDelegate:delegate];
}
then in the second class i'm calling it from this
[class1 setAudioDelegate:self];