[swift-evolution] AnyProtocol proposal

João Nunes joao3001 at hotmail.com
Wed Feb 17 13:37:59 CST 2016

The code is for a delegate. Thus it needs a protocol not a class. 

If you use a class and not a protocol, your delegate wont be able to subclass any other class to implement the "protocol" because it is a class.

The same applies if the uitableview delegate was declared as a class. You couldn't subclass a viewcontroller and still conform to the tableview delegate protocol.


Sent from my iPhone

> On 17 Feb 2016, at 21:12, Sune Foldager <cyano at me.com> wrote:
>> On 17 Feb 2016, at 18:59, João Nunes via swift-evolution <swift-evolution at swift.org> wrote:
>> In the example given. How would you restrict the generic type to a protocol without the use of AnyProtocol ?
> But what would you gain from restricting to just protocols? What could go wrong if someone passed in a class?
> -Sune
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160217/55412b78/attachment.html>

More information about the swift-evolution mailing list