swift中的 isKindofClass

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.

来自网址


你可能感兴趣的:(swift中的 isKindofClass)