iOS App Development Book/Video Series

General Category => FAQs => Topic started by: kjmcneish on September 11, 2015, 09:24:58 PM

Title: Fixing the "enumerate is unavailable" error in Swift 2.0
Post by: kjmcneish 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 (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 (https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8)