Author Topic: Fixing the "enumerate is unavailable" error in Swift 2.0  (Read 3975 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Fixing the "enumerate is unavailable" error in Swift 2.0
« on: September 11, 2015, 09:24:58 PM »
The enumerate free function has been removed in Swift 2.0 and replaced with the enumerate method on collections. To fix the error, replace the reference to the free function with a reference to the new method.

For example, the following code, which uses the enumerate free function:

Code: [Select]
for (cornerMatrixIndex, cornerMatrix) in enumerate(cornerMatrices) {
}

Can be changed to this:

Code: [Select]
for (forkPositionIndex, forkPosition) in forkPositions.enumerate() {
}

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8
« Last Edit: November 15, 2015, 10:12:30 AM by kjmcneish »