 <p>Since <code>x</code> has been declared as <code>var</code>. Closure will capture <code>x</code> as mutable version. Therefore, <code>x</code> will increase overtime when the loop pass.</p> <p>You can capture <code>x</code> with <code>let</code>. Since <code>let</code> is immutable . It will never be changed. Use that value inside the closure. For example</p> <pre><code>for var x = 0; x &lt; tableArray.param.count; ++x { let capturedX = x // do something with capturedX self.tableArray.param[capturedX].revision = rev.stringValue } </code></pre> <p>or just use range loop. It's more elegant and clean.</p> <pre><code>for x in 0..&lt; tableArray.param.count{ // do the same way you do with x // ... } </code></pre>