Tutorial :Call a method in the initiator class from the instantiated class obj-c


I have a button class - when the button is clicked, the playFile method of the MyAudio class is called. So my question is, its trivial to call the playFile method from the button class, but how do I call the method displayStopButton from the initiator class?

button class

- (void)myButtonClicked: (id)sender  {      [MyAudio playFile];    }    -(void)enablePlayButton  {    // test  }  

MyAudio class

-(BOOL)playFile{       // Init AVAudioPlayer  }    - (void)audioPlayerDidFinishPlaying: (AVAudioPlayer*)player successfully: (BOOL)flag  {       // make a call back to calling class????    }  


What you are calling your Button class looks like your controller class. The audioPlayerDidFinishPlaying sounds like a method that should also be implemented in your controller class. That way, you can set your controller class to be a delegate of the audio player class, and the implementation for the audioPlayerDidFinishPlaying method can make the call to [self displayStopButton].


You have to keep a pointer you all the controls you want to enable and disable in the controller. Using these handles you can turn them on and off as you get notificaitons fro the Audio sub-system.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »