1

关于Swift中的隐式成员表达式,我遇到了一些不一致的行为:

import UIKit

let button = UIButton()
button.backgroundColor = .brownColor() # works
button.setTitleColor(.brownColor(), forState: .Normal) # doesn't work
button.setTitleColor(UIColor.brownColor(), forState: .Normal) # works

在作业中使用前导点表示法时,所有工作都按预期工作。当使用它作为函数的参数时,swift 会抛出编译器错误(操场崩溃)。为了使情况复杂化,UIControlState枚举正确地插入了隐式成员表达式值。

这是一个错误吗?

4

1 回答 1

0

这是一个错误,至少在最新的 Swift 版本 2.1 中已修复

于 2016-02-13T23:26:15.577 回答