Warning: Unimplemented Selector localizedCaseInsensitiveCompare
Asked Answered
G

1

8

I'm getting the subject warning on the following line:

   NSSortDescriptor * sort = [ [NSSortDescriptor alloc] initWithKey:@"name"
                                 ascending:YES
                                  selector:@selector(localizedCaseInsensitiveCompare:) ];

And I didn't always get that warning. That is, the warning just started to appear recently, possibly due to a change in compilation settings. I don't see a typo, here. This looks (to me) just like code I've seen in many examples. I'm not seeing a run time exception. But I don't like warnings. Anyone seen this? Any idea what's triggering it?

Guajardo answered 3/4, 2012 at 13:29 Comment(0)
R
14

Did you turn on -Wselector? (Also called "Multiple Definition Types for Selector.") This warning is incompatible with Foundation and you should not turn it on. It exists because it does make sense in "pure" Objective-C. Just not in any Objective-C you'd ever be likely to write (i.e. anything that uses Cocoa).

The warning you want is -Wundeclared-selector, also called "Undeclared Selector."

It's somewhat dated, but I've compiled a complete list of GCC warnings and whether to turn them on or off in my Shared.xcconfig file. There is also a very helpful bestiary compiled by Jean-David Gadina that is a bit more up-to-date.

Renter answered 3/4, 2012 at 13:48 Comment(2)
Hi @Rob Napier, I just updated to xcode 5 and I am getting the warning "Selector not found", As you suggested I checked the option "Multiple Definition Types for Selector", and its already set to NO. But still I get the warning. So what to do.Goodloe
That's a different warning than this question is about. If you're getting that warning after upgrading, that suggests that you're using a method that has been removed. You should open a new question with details of what method you're using, what SDK you're using, and the exact warning (though I would start by just verifying that the method actually exists).Renter

© 2022 - 2024 — McMap. All rights reserved.