Xcode / Static Analyzer: Suppress Delay / Leak Warning

I have a function that creates a variable but does not free it. It passes this object with a message to another function that is related to memory management.

My question is, how can I suppress a static analyzer warning for what Xcode considers an overridden variable? I thought I could use NS_RETURNS_RETAINED for the function that creates it, but that doesn't work. I wonder if this is due to the fact that the variable is transmitted through the message?

+4
source share
2 answers

You can suppress a memory warning by doing the following:

  • Choose a target
  • Choose build phase
  • Select relevant sources
  • Locate the file for which you want to stop the warning.
  • Set the compiler flags by double-clicking on it:

    -w -Xanalyzer -analyzer-disable-checker

+4
source

I do not recommend that warnings be suppressed because they exist for a good reason. Well-coded applications have many tests with little or no memory leaks.

However, you can turn off warnings in Xcode 4 by going to the Xcode inspector and typing "memory" in the search box. There will be a column with the corresponding option. On the right there is an option that you can select.

0
source

Source: https://habr.com/ru/post/1314053/


All Articles