title: Using dispatchQueue in loops
body: <p>I am attempting to loop something with a delay (just as a proof of concept) this is for something else. But to simplify it, here is an example.</p>
  
  <p>so in this example, I have a string with "text" and I want to loop the addition of another string lets say 10 times. The only thing is that I want there to be a delay in each iteration. here is my code thus far.</p>
  
  <p>// global variable</p>
  
  <p>var myString = "text"</p>
  
  <p>// an action inside a button</p>
  
  <pre><code>    let delayInSeconds = 1.0
      DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + delayInSeconds) {
  
          for _ in 1...10 {
             self.myString += "another text"
          }
      }
      labelOne.text = myString
  
  }
  </code></pre>
  
  <p>I should add that the result is that all 10 "another text" are added immediately without any delay. </p>
  
  <p>thank you</p>