title: iOS Swift App Crashing: Array Index out of Range
body: <p>When I run the game, it will usually crash around the 19th wall, proceeding to tell me that "Array index out of range". Im not so fond of swift and have spent an hour so far without success. How to resolve error?    </p>
  
  <pre><code>import Foundation
  import UIKit
  
  let kMLGroundHeight: CGFloat = 20.0
  
  let kDefaultXToMovePerSecond: CGFloat = 320.0
  
  //CollisionDetection
  
  let heroCategory: UInt32 = 0x1 &lt;&lt; 0
  let wallCategory: UInt32 = 0x1 &lt;&lt; 1
  
  //Levels
  let kLevelGenerationTimes: [NSTimeInterval] = [0.8, 0.7, 0.6, 0.4, 0.3]
  let kNumberOfPointsPerLevel = 5
  </code></pre>