Search code examples
objective-cxcodeclang-static-analyzer

XCode/Static Analyzer: Suppressing a retain count/leak warning


I have a function that is creating a variable, but not deallocating it. It passes this object on with a message to another function that deals with the memory management.

My question is how do I suppress the static analyzer warning for what XCode thinks is an over-retained variable? I thought I could use NS_RETURNS_RETAINED for the function that is creating it, but that doesn't work. I wonder if it has something to do with the fact that the variable is passed on through a message?


Solution

  • You can suppress the memory warning by doing the following:

    1. Select target
    2. Select build phase
    3. Select complile sources
    4. Find file for which you want to suppress warning.
    5. Set compiler flags to following by double clicking on it:

      -w -Xanalyzer -analyzer-disable-checker