Using isKindOfClass with Swift

I’m trying to pick up a bit of Swift lang and I’m wondering how to convert the following Objective-C into Swift:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];

    UITouch *touch = [touches anyObject];

    if ([touch.view isKindOfClass: UIPickerView.class]) {
      //your touch was in a uipickerview ... do whatever you have to do
    }
}

More specifically I need to know how to use isKindOfClass in the new syntax.

override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {

    ???

    if ??? {
        // your touch was in a uipickerview ...

    }
}

5 Answers
5

Leave a Comment