1st Edition Errata


#1

No, that doesn’t mean we’ve already got a 2nd Edition :wink:

Over time, an errata post will be made in the forum for each chapter, and they will all be linked from this post. Some good feedback has already been submitted, and will be noted here (and in the chapters’ respective posts) over the coming days and weeks.

Errata for Chapter 27: Your First iOS Application
Errata for Chapter 28: Your First Cocoa Application


#2

I got the book (second printing) on Friday.

on page 32 of chapter 5, one is supposed to #include to get rid of the warning about the implicit use of sleep().

Doing so did not eliminate the error.

I poked around and found sleep() in <unistd.h> . When I #included this file, the warning went away. The search of the documentation did not show sleep() in any other library.

This may be related – on p28, the warning about the lack of a function prototype did not appear.

Xcode version 4.3.2 (4E2002), and OS X 10.7.3


#3

Please Help!
The Second Edition, page 11 shows:
int main (int argc, const char * argv[]) {
While Xcode returns:
int main(int argc, const char * argv[])
{

  1. Which is correct and why?
  2. Does this cause or contribute to the errata comments about pages 28 and 32 by geo3rge and if so how, whatever and why etc.?

Thanks…


#4

Now that I typed the exact syntax:
#include <stdio.h>

int main (int argc, const char * argv[]) {

// insert code here...
printf("Hello, World!\n");
return 0;

}
the program now runs and returns:
Hello, World!
but the question still remains, why does Xcode return the following incorrect syntax which does not compile and run?
int main(int argc, const char * argv[])
{
instead of:
int main (int argc, const char * argv[]) {
which does compile and run! ???

Thanks…


#5

This build compiled and ran:
#include <stdio.h>

int main (int argc, const char * argv[])
{
// Print the beginning of the novel
printf(“It was the best of times.\n”);
printf(“It was the worst of times.\n”);
/* Is that acrially any good?
Maybe it needs a rewrite. */

return 0;

}
and returned the correct Output:
It was the best of times.
It was the worst of times.
but again, why is Xcode returning the slightly incorrect syntax that has to be corrected before I can compile and run and get the correct return?

Thanks…


#6

johnhook–

If I understand correctly, your question has to do with the placement of the opening bracket.

Whitespace doesn’t count in c, so if you place the bracket and then have a return, or have a return and then the opening bracket, it does the same thing.

This is a matter of ‘taste’. You get it for if-then syntax as well.

Some prefer

if () {

}

and some prefer

if (condition)
{

}

The Xcode default is to do the former. I prefer the latter, having learned it is easier to parse when scanning visually.

However, both mean the same thing.


#7

Hello Turner,

As a newbe I need to see exactly what I will see, exactly as returned by Xcode, or I will be distracted from the lesson. I, and I’m sure many others, may/will be distracted. Aaron may want to note this in the book, IN BIG BOLD LETTERS!

Why not use EXACTLY the same syntax as Xcode will return?

Thanks,

John


#8

@geo3rge
I also experienced the sleep() error on page 32 of the first edition. I found sleep() in both libc.h and unistd.h libraries. At least it taught me where to look for library documentation. I used http://www.gnu.org/software/libc/manual/html_node/Sleeping.html#Sleeping


#9

Just a small one:

p210, the comment in the new code added in the implementation should be bolded as it is new code (well sorta).
// Set the product name
to
// Set the product name


#10

johnhook: The answer to your question about using the text exactly as it appears in Xcode is an unfortunate one: Xcode’s templates and sample code change regularly. So regularly, that keeping up with small syntactical changes in text is nearly impossible.

In fact, with the curly-bracket-on-same-line-or-next-line that geo3rge mentioned, Xcode itself is inconsistent. Creating a new file that contains template code usually has method/function implementations with the curly bracket on the next line, however, you’ll see in later chapters that some of the code that Xcode can generate on your behalf places the curly bracket on the same line.

We are happy to help understand any discrepancies between what you see in the book and on the screen, but that such discrepancies will crop up is unfortunately inevitable. :-/

~Mikey


#11

In Chapter 12, Objects, the code examples appear like they may be out of date for Xcode 4.4.1.

@autoreleasepool doesn’t seem to be supported. NSDate isn’t recognized. NSLog triggers a deprecation style warning for C99.

Has that much changed for Obj-C?


#12

It looks like I selected Core Foundation instead of Foundation in project type. My mistake.


#13

Chapter 4, Page 24, Table 4.2

“(If you are coming from another language, note that there is no logical exclusive OR in Objective-C, so we won’t discuss it here.)”

The following code is valid Objective-C code:
if((10 < 20) ^ (20 < 10)) {
printf(“The expression is true.”);
}

Am I misunderstanding the text, or is this errata?


#14

[quote=“Unranking”]Chapter 4, Page 24, Table 4.2

“(If you are coming from another language, note that there is no logical exclusive OR in Objective-C, so we won’t discuss it here.)”

The following code is valid Objective-C code:
if((10 < 20) ^ (20 < 10)) {
printf(“The expression is true.”);
}

Am I misunderstanding the text, or is this errata?[/quote]

That’s bitwise XOR, which is not entirely the same as logical XOR. Logical operators will only return 0 or 1 (that is, NO or YES), but bitwise operators may return any number of values, depending on their arguments!


#15
  1. Your First Cocoa Application > A look at Interface Builder

All buttons on the line are “inspector”, not only this one.