O'Reilly logo

Xcode 4 iOS Development by Steven F. Daniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – detecting an instance of an uninitialized variable

Another type of common error made by developers is variables which have not been initialized upon being declared. Fortunately, the Static Analyzer can also catch these types of bugs.

To demonstrate how the Static Analyzer helps detect instances of uninitialized variables, we will use the following code:

  1. Open the file main.m located within the Supporting Files folder of your project.
  2. Enter the following piece of code as shown in the snippet below:
// ---------------------------------------------------------- // Example: Uninitialized Variable being declared // ---------------------------------------------------------- int setReturnValue(int _varX) { int number; if (_varX > 100) { ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required