I have a UILabel that needs to change its text to the next item in an array after a certain amount of time. I'm using a for-in loop to achieve this. My issue, though, is that the label won't change until the loop is complete, which defeats the purpose. I have done a lot of searching, and it seems as though using dispatch_async(dispatch_get_main_queue()... is the way to do this. I have tried to use it as other people have, but it doesn't update the label's text. So, if someone could help me use it in my code, or has a solution to update the text in the loop, it would be appreciated.
My code:
@IBAction func startEndTouch(sender: AnyObject) {
var wordsPerMinVal:Double = 60.0/sliderValueBen
for item in textEnterGo {
delay(wordsPerMinVal){
self.yourWordsLabel.text = item
print(item)
}
}
}
Two places I got some info from: