[swift-evolution] Specify type of a delegate which conforms to a protocol
alex at ateamer.de
Tue Feb 9 12:47:17 CST 2016
As for a new syntax, I was also thinking about this issue a few days ago and it occurred to me that there are even more types that cannot be properly represented in Swift. For example there is currently no way (that I know of) to create a variable that can contain any enum that is backed by a String. However, these kinds of constraints can easily be specified in generic constraints (the ones in angle brackets). Maybe we could add the same syntax for variables/constants as well so that the code would look something like the following for your issue:
var<T, where T: UIViewController, T: MyProtocol> myVar: T
or for enums backed by a String:
var<T: RawRepresentable where T.RawValue == String> myVar: T
Tell me what you think about it.
> On 09 Feb 2016, at 15:58, Inder Kumar Rathore . via swift-evolution <swift-evolution at swift.org> wrote:
> Hi All,
> I used to do this in Obj-C but I'm unable to do this in swift
> UIViewController<MyProtocol> *delegate;
> I posted this question on dev forums but didn't get the solution and finally I'm reporting here so that It can be added as a features in the coming releases.
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution