title: ios visuals not updating while process takes place. (Swift 3)
body: <p>I have a process that takes some time to process:</p>
  
  <pre><code>for n in 0..&lt;currentAmount {
      if gcd(random(max: Int(randRange.value)), random(max: Int(randRange.value))) == 1{
          gcdCounter += 1
      }
      piProgress.setProgress(Float(Double(n)/Double(currentAmount)), animated: false)
  }
  </code></pre>
  
  <p>Firstly, the progress bar is referenced correctly. There seems to be something going on that I'm unaware of as when the button that activated this loop enters, the button stays 'greyed out' until the loop is done and the progress bar doesn't update at all. If I replaced the last line in the loop with </p>
  
  <pre><code>print(Float(Double(n)/Double(currentAmount))
  </code></pre>
  
  <p>I can see the progress pass perfectly well in the console, so why isn't the view updating? I read on <a href="https://stackoverflow.com/questions/24147931/ui-is-not-updating-while-some-function-takes-time-to-execution">another thread</a> it's to do with which threads the processes are running on, but that's in objective-c I think, not Swift 3. Please help. I like to see my app doing <em>something</em>. </p>
  
  <p>EDIT: After looking through, I found this resource very useful for learning GCD: <a href="http://www.appcoda.com/grand-central-dispatch/" rel="nofollow noreferrer">http://www.appcoda.com/grand-central-dispatch/</a></p>