[swift-evolution] [Proposal] Make optional protocol methods first class citizens

Rob Mayoff mayoff at dqd.com
Thu Mar 31 11:37:03 CDT 2016


On Thu, Mar 31, 2016 at 10:56 AM, Thorsten Seitz via swift-evolution <
swift-evolution at swift.org> wrote:

>
> protocol UIGestureRecognizerDelegate {
>     var gestureRecognizerShouldBegin: ((gestureRecognizer:
> UIGestureRecognizer) -> Bool)? { get }
> }
>

UIGestureRecognizerDelegate has five methods that are "named"
gestureRecognizer:


   - gestureRecognizer(_:shouldRecognizeSimultaneouslyWithGestureRecognizer:
   )
   - gestureRecognizer(_:shouldRequireFailureOfGestureRecognizer:)
   - gestureRecognizer(_:shouldBeRequiredToFailByGestureRecognizer:)
   - gestureRecognizer(_:shouldReceiveTouch:)
   - gestureRecognizer(_:shouldReceivePress:)

You can only have a single property named "gestureRecognizer", so you
either have to come up with other names for these, or change the language
to allow closure-typed properties to have multipart names.

This problem has been noted before, for example here:
http://article.gmane.org/gmane.comp.lang.swift.evolution/8707/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160331/9e3a1be1/attachment.html>


More information about the swift-evolution mailing list