枚举不可用在序列上调用枚举方法 [英] enumerate is unavailable call the enumerate method on the sequence
本文介绍了枚举不可用在序列上调用枚举方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
只需下载Xcode 7 Beta,并在枚举时出现此错误
Just downloaded Xcode 7 Beta, and come up with this error on enumerate
错误:
enumerate不可用,在序列上调用enumerate方法
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
}
}
}
推荐答案
在Swift 2中,enumerate
不再是全局函数,它是SequenceType
的扩展.
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() {
// ...
}
这篇关于枚举不可用在序列上调用枚举方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文