title: Swift - How to know when a loop has ended?
body: <p>Please, forgive me as i'm <strong>very</strong> new to swift, and programming in general.</p>
  
  <p>Believe me when I say I've tried hard to understand this, but I simply can't and would greatly appreciate any help. </p>
  
  <p>say I have this function:</p>
  
  <pre><code>func loop() {
    for var i=0; i&lt;5; i++ {
    println(i)
    }
  }
  </code></pre>
  
  <p>and I wanted to print to the logs "loop has finished" once this loop had completed and finished running, how would I do this? If i do: </p>
  
  <pre><code>func loop() {
    for var i=0; i&lt;5; i++ {
    println(i)
    println("loop has finished")
    }
  }
  </code></pre>
  
  <p>then "loop has finished" gets printed after every time i is incremented. </p>
  
  <p>I've tried reading into closures and completion handlers, but it's all going over my head at the moment and I don't really understand how i'd achieve the task above. </p>
  
  <p>If there's an angel that can show me how I'd complete my above example, I'd be in your debt.</p>
  
  <p>Thankyou for your patience with my currently pathetic knowledge!</p>