为什么以下Swift3代码在Xcode 8中导致错误value of type (NSObject) -> () -> MyView has no member getSomeButton
?
lazy var someButton = {
return self.getSomeButton // ERROR
}()
private func getSomeButton() -> UIButton {
return UIButton()
}
答案 0 :(得分:1)
实际上,错误消息完全是误导性的,应该是can't infer closure return type
。指定变量类型可以解决问题。希望这有助于某人。
lazy var someButton: UIButton = {
return self.getSomeButton // OK
}()