加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift – enumerate不可用调用序列上的枚举方法

发布时间:2020-12-14 05:43:22 所属栏目:百科 来源:网络整理
导读:参见英文答案 Swift 2.0 : ‘enumerate’ is unavailable: call the ‘enumerate()’ method on the sequence3个 刚刚下载了Xcode 7 Beta,并在枚举时出现此错误 错误: enumerate is unavailable call the enumerate method on the sequence func layoutSpec
参见英文答案 > Swift 2.0 : ‘enumerate’ is unavailable: call the ‘enumerate()’ method on the sequence3个
刚刚下载了Xcode 7 Beta,并在枚举时出现此错误

错误:

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中,枚举不再是一个全局函数,它是SequenceType的扩展.

直接在序列上调用它来枚举如下:

for (index,key) in row.enumerate() {
    // ...
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读