将不明确的引用转换为 swift 3
convert ambiguous reference to swift 3
我正在尝试转换为 Swift 3 并收到以下错误:
'?' must be followed by a call, member lookup, or subscript
我的代码:
var superview = containerView.superview
if type(of: superview?) === UIWindow.self { //I GET AN ERROR HERE
superview = containerView
}
建议?
测试类型最简单、最自然的方法是 is
关键字:
var superview = containerView.superview
if superview is UIWindow {
superview = containerView
}
我正在尝试转换为 Swift 3 并收到以下错误:
'?' must be followed by a call, member lookup, or subscript
我的代码:
var superview = containerView.superview
if type(of: superview?) === UIWindow.self { //I GET AN ERROR HERE
superview = containerView
}
建议?
测试类型最简单、最自然的方法是 is
关键字:
var superview = containerView.superview
if superview is UIWindow {
superview = containerView
}