Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enumerate is unavailable call the enumerate method on the sequence [duplicate]

Tags:

ios9

swift

Just downloaded Xcode 7 Beta, and come up with this error on enumerate

error:

enumerate is unavailable call the enumerate method on the sequence

 func layoutSpecialKeysRow(row: [Key], keyWidth: CGFloat, gapWidth: CGFloat, leftSideRatio: CGFloat, rightSideRatio: CGFloat, micButtonRatio: CGFloat, isLandscape: Bool, frame: CGRect) -> [CGRect] {
    var frames = [CGRect]()

    var keysBeforeSpace = 0
    var keysAfterSpace = 0
    var reachedSpace = false
    for _k, key) in enumerate(row) {
        if key.type == Key.KeyType.Space {
            reachedSpace = true
        }
        else {
            if !reachedSpace {
                keysBeforeSpace += 1
            }
            else {
                keysAfterSpace += 1
            }
        }
    }
like image 690
MarinaIOS Avatar asked Jul 05 '15 13:07

MarinaIOS


People also ask

Does OrderedDict remove duplicates?

The OrderedDict. fromkeys() method eliminates the duplicates from the list because the dictionary in Python cannot have duplicate keys. This is the fastest method in python to remove duplicates values from a list.


1 Answers

In Swift 2, enumerate is not a global function anymore, it's an extension of SequenceType.

Call it directly on the sequence to enumerate like this:

for (index, key) in row.enumerate() {
    // ...
}
like image 186
Eric Aya Avatar answered Oct 16 '22 15:10

Eric Aya