Use #pragma to remove warnings ⚠️

The basic grammar

#pragma clang diagnostic push
#pragma clang diagnostic ignored "- Related commands"
    // Your own code
#pragma clang diagnostic pop
Copy the code

Ignore the warning type commonly used on iOS

1. No variable warning is used

#pragma clang diagnostic push   
#pragma clang diagnostic ignored "-Wunused-variable"  
    NSInteger variableValue;   
#pragma clang diagnostic pop
Copy the code

2. Method deprecation warnings

#pragma clang diagnostic push   
#pragma clang diagnostic ignored "-Wdeprecated-declarations"  
    // Some function be deprecated   
#pragma clang diagnostic pop
Copy the code

3. Incompatible pointer types

#pragma clang diagnostic push   
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"  
   //  
#pragma clang diagnostic pop
Copy the code

4. Circular references

#pragma clang diagnostic push  
#pragma clang diagnostic ignored "-Warc-retain-cycles" 
   // Circular reference
#pragma clang diagnostic pop
Copy the code

5. Memory leak warning

#pragma clang diagnostic push  
#pragma clang diagnostic ignored   "-Warc-performSelector-leaks"
    // Memory leak warning
#pragma clang diagnostic pop
Copy the code

See this website for more warning typesfuckingclangwarnings