I'm new to iOS programming, I can't figure out how to solve this problem. I program the player using the method:

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag{ if (!flag){ NSLog(@"ERROR");} [_audioPlayer stop]; [self nextSong]; [self curTime]; } 

I determine whether this track has ended and reproduce the next one. But at the same time, the label with the name of the track and the label with its duration do not change (when you click the nextSong / prevSong buttons, everything is fine). Tell me how to fix it?

    1 answer 1

    Perhaps the UI update is not in the main thread. It is necessary to put a breakpoint in the place where the duration and name change - make sure which flow is the call. At the same time, make sure that there comes new data.

    If not in the main thread:

     dispatch_async(dispatch_get_main_queue(), ^{ // Обновление UI }); 
    • Why do you think so? - 0xdb
    • If you try to change the name of the label not in the main thread, nothing will change. dispatch_async (dispatch_get_main_queue (), ^ {/// update UI}); - Nikita Milko
    • No need to write comments. Under your message there is a button to edit, complete the answer. - 0xdb
    • That is, it was not necessary to respond to comments? I was not going to add anything in response. - Nikita Milko
    • No no need. Submit your answer. - 0xdb