<li><ahref="#dealloc_mrr">How do I tell the analyzer that my instance variable does not need to be released in -dealloc under Manual Retain/Release?</a></li>
<li><ahref="#use_assert">The analyzer assumes that a loop body is never entered. How can I tell it that the loop body will be entered at least once?</a></li>
<li><ahref="#suppress_issue">How can I suppress a specific analyzer warning?</a></li>
<p>You can tell the analyzer that this path is unreachable by teaching it about your <ahref ="annotations.html#custom_assertions">custom assertion handlers</a>. For example, you can modify the code segment as following.</p>
<p>The reason the analyzer often thinks that a pointer can be null is because the preceding code checked compared it against null. So if you are absolutely sure that it cannot be null, remove the preceding check and, preferably, add an assertion as well. For example, in the code segment above, it will be sufficient to remove the <tt>if (!b)</tt> check. </p>
<h4id="dead_store"class="faq">Q: How do I tell the static analyzer that I don't care about a specific dead store?</h4>
<p>When the analyzer sees that a value stored into a variable is never used, it's going to produce a message similar to this one:
<preclass="code_example">Value stored to 'x' is never read</pre>
You can use the <tt>(void)x;</tt> idiom to acknowledge that there is a dead store in your code but you do not want it to be reported in the future.</p>
<h4id="unused_ivar"class="faq">Q: How do I tell the static analyzer that I don't care about a specific unused instance variable in Objective C?</h4>
<p>When the analyzer sees that a value stored into a variable is never used, it is going to produce a message similar to this one:
<preclass="code_example">Instance variable 'commonName' in class 'HappyBird' is never used by the methods in its @implementation</pre>
You can add <tt>__attribute__((unused))</tt> to the instance variable declaration to suppress the warning.</p>
<h4id="unlocalized_string"class="faq">Q: How do I tell the static analyzer that I don't care about a specific unlocalized string?</h4>
<p>When the analyzer sees that an unlocalized string is passed to a method that will present that string to the user, it is going to produce a message similar to this one:
<preclass="code_example">User-facing text should use localized string macro</pre>
If your project deliberately uses unlocalized user-facing strings (for example, in a debugging UI that is never shown to users), you can suppress the analyzer warnings (and document your intent) with a function that just returns its input but is annotated to return a localized string:
<h4id="dealloc_mrr"class="faq">Q: How do I tell the analyzer that my instance variable does not need to be released in -dealloc under Manual Retain/Release?</h4>
<p>If your class only uses an instance variable for part of its lifetime, it may
maintain an invariant guaranteeing that the instance variable is always released
before -dealloc. In this case, you can silence a warning about a missing release
by either adding <tt>assert(_ivar == nil)</tt> or an explicit release
<tt>[_ivar release]</tt> (which will be a no-op when the variable is nil) in
<h4id="use_assert"class="faq">Q: The analyzer assumes that a loop body is never entered. How can I tell it that the loop body will be entered at least once?</h4>