Static Analyzer

From time to time, you should use the static analyzer to look for possible sources of error in your code; choose Product → Analyze (Shift-Command-B). This command causes your code to be compiled, and the static analyzer studies it and reports its findings in the Issue navigator and in your code.

The static analyzer is static — it’s analyzing your code, not debugging in real time — but it is remarkably intelligent and may well alert you to potential problems that could otherwise escape your notice. For example, there are two memory leaks in the Empty Window project as we’ve developed it in previous chapters; this is deliberate, because we haven’t yet discussed memory management (we’ll discuss it, and fix these leaks, in Chapter 12). The static analyzer correctly reports them.

The static analyzer isn’t perfect, and can result in false warnings, but think of it as notifying you of things to think about rather than as listing definite issues. For more about the static analyzer, see http://clang-analyzer.llvm.org.

Get Programming iOS 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.