> On Sep 22, 2016, at 9:51 PM, Gerriet M. Denkmann via swift-users
> 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:
> On 23 Sep 2016, at 14:19, Jacob Bandes-Storch via swift-users
> wrote:
>
> Once you’ve determined this object responds to the selector, how do you
> intend to use it?
The function containing “ if a.responds…” is helping me to understand the
layout of views in iOS.
The input is some object,
Once you've determined this object responds to the selector, how do you
intend to use it?
It's probably best to define your own protocol that has the requirement,
and then you can access it via the protocol. In fact, at that point you
might even be able to use "as?" rather than "respondsToSelector
> On 23 Sep 2016, at 12:09, Marco S Hyman wrote:
>
> On Sep 22, 2016, at 9:51 PM, Gerriet M. Denkmann via swift-users
> wrote:
>>
>> This line (Swift 3):
>> if a.responds(to: Selector(“viewControllers") )
>> creates this warning: Use '#selector' instead of explicitly constructing a
>> '
#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
#selector(MyVC.viewControllers).
On Thu, Sep 22, 2016 at 9:51 PM, Gerriet M. Denkmann via swift-users
Xcode will be happy if you add “@objc” in front of your “func” declaration.
> On 23 Sep 2016, at 2:51 PM, Gerriet M. Denkmann via swift-users
> wrote:
>
> This line (Swift 3):
> if a.responds(to: Selector(“viewControllers") )
> creates this warning: Use '#selector' instead of explicitly
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: Argume