How do I force one method to be executed before another method?

Posted by RexOnRoids on Stack Overflow See other posts from Stack Overflow or by RexOnRoids
Published on 2010-03-27T11:08:16Z Indexed on 2010/03/27 11:13 UTC
Read the original article Hit count: 476

I've got 2 methods. One method starts playing an audio file (.mp3), the other method updates a UIToolBar to show a button (PLAY or PAUSE). These two methods are called in the following order:

//Adds some UIBarButtonItems to a UIToolBar
[self togglePlayer];
//Uses AVAudioPlayer
[audioPlayer play];

I call the methods in the above order so that the (pause) button will be shown at the time the song starts playing. But, the problem is that the song starts playing first, and the UIToolBar remains unchanged for quite a while (from 2 to 5 secs) until the button is added and shown.

What I want is for the button to be shown at the same time the song starts playing (i.e. NO DELAY). Is there any way to do this?

© Stack Overflow or respective owner

Related posts about uitoolbar

Related posts about avaudioplayer