Understanding Errors and Warnings
Code is complex, and most code has errors. Two types of errors can occur:
Compile-time errors. These are also known as build-time errors. Xcode finds them while it builds your app.
Run-time errors. These occur after the app builds. Ideally, you try to catch them while the app is being tested, but it’s not unusual for apps to be released with run-time errors.
Understanding compile-time errors
Compile-time errors are basic errors in code. They’re the equivalent of obvious mistakes in English. When Xcode reports a compile-time error, it’s telling you that some part of your code doesn’t make sense and that you must fix the error before it can build the project.
The Editor looks for obvious errors as you type. Figure 5.1 shows an example: a missing semicolon. (You’ll find more about semicolons in code later in this chapter.)
The error is indicated with a red marker to the left of the code. Note that Xcode includes five features to help you code correctly.
Xcode tries to anticipate the code you want to type as you type it. To accept a guess, press Enter. Otherwise, keep typing to see more accurate guesses. If there are multiple fields in a guess, you can ...