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.
网友评论