Sometimes (many times!) code does not compile properly, as you can see in the PB window in Figure 5-27.
If instead of a clean compile you get compiler warning or error
messages, you have probably made a typographical error at some point
in the code. For example, the error message in Figure 5-27 was generated by removing the first semicolon
from the displayX method in the
Controller.m
file (the semicolon is missing from
the statement above the highlighted statement at the bottom in Figure 5-27).
If you click on an error message in the top-right panel of
PB’s window (e.g., “syntax error,
found
’setStringValue’”),
the offending line of code will be highlighted in the source code
file, Controller.m
. If you double-click the
error message, a new window will open with the line containing the
error highlighted (actually, the error is in the previous line, but
it doesn’t cause a problem until the highlighted
line). This is a great help in finding and fixing compiler errors!
If you get compiler errors for source code that you type in from this book, we suggest that you first reexamine your code line by line, rather than downloading our code from the Web. Examining code for errors is an important skill to develop.
As an alternative to double-clicking an error message, you can open
the Controller.m
file in a PB editor window,
type Command-L to bring up the Goto panel, enter
“45” (the line where the error was
reported), and inspect the code on line 45 and previous lines.
(If you compiled your program from within GNU Emacs, you can use the Emacs command “goto-next-error” to automatically jump to the file and line containing the error.)
18.225.255.187