[swift-users] Swift 3 likes to tease me

Jacob Bandes-Storch jtbandes at gmail.com
Fri Sep 23 01:34:36 CDT 2016

#selector is not used with a string, but with an actual reference to a
method. If, for instance, you have a protocol MyVC which declares `var
viewControllers: ...` then you can use something like

On Thu, Sep 22, 2016 at 9:51 PM, Gerriet M. Denkmann via swift-users <
swift-users at swift.org> wrote:

> This line (Swift 3):
>         if a.responds(to: Selector(“viewControllers") )
> creates this warning: Use '#selector' instead of explicitly constructing a
> 'Selector'
> Ok. Following this advice I change it to:
>         if a.responds(to: #selector(“viewControllers"))
> and now get an error instead: Argument of ‘#selector' does not refer to an
> '@objc' method, property, or initializer
> Why do I get punished for following Xcode’s advice?
> Gerriet.
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160922/ef663eff/attachment.html>

More information about the swift-users mailing list