swift中的 isKindofClass
2017-12-24 本文已影响0人
不要虚度美好的时光
The proper Swift operator isis:
if touch.view is UIPickerView {
// touch.view is of type UIPickerView
}
Of course, if you also need to assign the view to a new constant, then theif let ... as? ...syntax is your boy, as Kevin mentioned. But if you don't need the value and only need to check the type, then you should use the is operator.