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?
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.