In a previous post I talked about getting clang to be quite, ie every once in a blue moon you want a warning to simply go away. As I said, I’m really not a big fan of doing this, a warning usually means that something is wrong and you should fix it and not just ignore it.
For that once in a blue moon event I’ve got more detail on how to turn the warning suppression from a blunt instrument to a nice precision surgical instrument.
Inserting the following line in your code will suppress ARC performSelector warnings.
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
If you add a little more code
#pragma clang diagnostics push #pragma clang diagnostic ignored "-Warc-performSelector-leaks" // code that needs a warning suppressed #pragma clang diagnostics pop
You limit the impact of the suppression to just the bounds of the push and pop.
Of course the next part of the magic act is to figure out what exactly is the warning you want to suppress. Xcode does a fantastic job of giving you the human readable version. It actually gives you a running start before you slam into the brick wall. The problem is that there doesn’t appear to be a very good/complete list of human redable warnings and their official flag counterparts. So, what is one to do now?
Turn out that if you’re willing to peal away a layer of Xcode you can find the actual warning flag. Start by compiling your code, which will bring up the warning. Next, press Apple-7. This will bring up the Log Navigator. Click on the top log and scroll down until you find your warning. Click the detail button, its the rounded button with a set of horizontal lines. Now you see behind the Xcode curtain and see the gory detail. The top part of the details is the exact command used to compile your problem file. The bottom part gives you the details of the warning. If you examine the warning you’ll see that the ling ends with a [-Wwarning]. That’s it. This is the flag you want.
This is where I found info about the warning suppression push and pop ‘Disabling Clang Compiler Warnings’