Skip to content

Latest commit

 

History

History
26 lines (21 loc) · 1.07 KB

how-to-ignore-clang-diagnostics.md

File metadata and controls

26 lines (21 loc) · 1.07 KB

How To Ignore Clang Diagnostics

📓

Scenario:
Clang would issue some warning about our coding style or some semantics but we just don't need this warning in some case such as the case in code snippet in AFNetworking, which is mentioned in NSHipster's post.

Solution:
Learned from NSHipster's post, we can use #pragma to deal with it. Check the following code snippet:

// completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
    self.completionBlock = ^ {
        ...
    };
#pragma clang diagnostic pop

Just use push and pop to turn warning off for the specific code block. This is the example in AFNetworking library to disable diagnostic about retain cycle issue in completionBlock.

Reference