I have a variable that must be a UIView
that also implements the protocol MTMathKeyboard
.
I've tried,
var keyboard: (UIView & MTMathKeyboard)
var keyboard: UIView<MTMathKeyboard>
What's the syntax for a non-generic class instance that implements a protocol?
In Swift 4 you can use:
let keyboard: UIView & MTMathKeyboard
I think you should go this way:
protocol MTMathKeyboard: class {
}
class YourClass<MTMathKeyboard where T:UIView> {
var keyboard: T!
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With