In objective-c, I can declare a method with a return type:
-(UIView<MyProtocol> *)someMethod;
In this example, the method returns a UIViewthat matches the protocol MyProtocol.
I want to make something like this quick:
protocol MyProtocol {
var someProperty : Int {get set}
}
protocol MyDelegate {
func someMethod() -> UIView : MyProtocol
}
In general, the delegate should return UIViewwith var " someProperty"
I do not want to define a specific class UIView. I want the user to be able to return any type UIView(as long as it conforms to the protocol)
The syntax I wrote is invalid - how do I write it?
source
share