<div dir="ltr">Once you&#39;ve determined this object responds to the selector, how do you intend to use it?<div><br></div><div>It&#39;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 &quot;as?&quot; rather than &quot;respondsToSelector&quot;.</div><div><br></div><div>What are you trying to do exactly?</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Thu, Sep 22, 2016 at 11:57 PM, Gerriet M. Denkmann <span dir="ltr">&lt;<a href="mailto:g@mdenkmann.de" target="_blank">g@mdenkmann.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
&gt; On 23 Sep 2016, at 12:09, Marco S Hyman &lt;<a href="mailto:marc@snafu.org">marc@snafu.org</a>&gt; wrote:<br>
<span class="">&gt;<br>
&gt; On Sep 22, 2016, at 9:51 PM, Gerriet M. Denkmann via swift-users &lt;<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; This line (Swift 3):<br>
&gt;&gt;      if a.responds(to: Selector(“viewControllers&quot;) )<br>
&gt;&gt; creates this warning: Use &#39;#selector&#39; instead of explicitly constructing a &#39;Selector&#39;<br>
&gt;&gt;<br>
&gt;&gt; Ok. Following this advice I change it to:<br>
&gt;&gt;      if a.responds(to: #selector(“viewControllers”))<br>
&gt;<br>
</span>&gt; #selector does not take a string.   It takes a method name.  This is required as the name needs to be mangled/demangled in the conversion between obj-c and swift.<br>
&gt;<br>
&gt; You might need the class name, too, e.g. #selector(MyClass.<wbr>viewControllers)<br>
<br>
This might be difficult. viewControllers is a property used in several classes, e.g. UIPageViewController, UISplitViewController, etc.<br>
<br>
Xcode has just given me a new suggestion (probably it noticed that I was not quite happy with its former hint):<br>
        if a.responds(to: #selector(getter: UINavigationController.<wbr>viewControllers))<br>
but I do not want to be restricted to this special class.<br>
My a is AnyObject and should be treated as such.<br>
<br>
Kind regards,<br>
<br>
Gerriet.<br>
<br>
<br>
</blockquote></div><br></div></div>