Note that there are some explanatory texts on larger screens.

plurals
  1. POIn Objective-C, is there a way to specify which definition of a selector you want @selector() to use?
    primarykey
    data
    text
    <p>Xcode 4 is giving me (rather unhelpful) errors about "unimplemented selector 'xxx'" when I try to use @selector(xxx) with any method not actually defined in the same source file. The error goes away (at least for the project build) if I set the LLVM compiler warning, "Multiple Definition Types for Selector" to "No". (This is the iOS default, but for my project it had been enabled.) <strike>However, even with this off, the error still shows up in the editor if "Enable live issues" is checked in the Build Settings dialog.</strike></p> <p>So now I've turned off live issues so as not to be distracted, which is a bit of a let down. My question is: Is there a way I can get rid of the error by, perhaps, specifying which definition of a selector I want to use? Or should it even matter, i.e. do all definitions of a method share the same selector in Objective-C? Is this a compiler bug, or perhaps a bogus setting that I should just leave off? <strike>(And if the latter, why is it on for the live build feature in the new editor?)</strike></p> <p>Here's the code, just to be clear:</p> <pre><code>if ([recognizer respondsToSelector:@selector(translationInView:)]) { ... } </code></pre> <p>And here's the error:</p> <pre><code>error: unimplemented selector 'translationInView:' [-Wselector,2] if ([recognizer respondsToSelector:@selector(translationInView:)]) { ^ </code></pre> <p>If I replace 'translationInView:' with a method defined in the same source file, there's no error. I've imported the header which defines this method, and I've tried declaring the method in a category within this source file. Doesn't matter.</p> <p>I'm leaving the warning off and live builds off and moving on for now, but I'd love to find a better resolution for this issue. At the very least, I'd like to learn whether Objective-C's @selector has a syntax for selecting a particular definition of a method, since I have not found any sign of this anywhere so far.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload