1st Edition Errata

General comments and announcements about "Objective-C Programming: The Big Nerd Ranch Guide"

Moderator: MikeyWard

1st Edition Errata

Postby MikeyWard » Thu Dec 29, 2011 6:04 pm

No, that doesn't mean we've already got a 2nd Edition ;)

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
MikeyWard
Site Admin
 
Posts: 179
Joined: Thu May 13, 2010 10:06 pm

Re: 1st Edition Errata

Postby geo3rge » Sun Apr 01, 2012 4:14 pm

I got the book (second printing) on Friday.

on page 32 of chapter 5, one is supposed to #include <stdlib> 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
geo3rge
 
Posts: 4
Joined: Sun Apr 01, 2012 4:00 pm

Re: 1st Edition Errata

Postby johnhook » Sun Apr 01, 2012 9:39 pm

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...
johnhook
 
Posts: 5
Joined: Sun Apr 01, 2012 9:23 pm

Re: 1st Edition Errata

Postby johnhook » Sun Apr 01, 2012 10:55 pm

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...
johnhook
 
Posts: 5
Joined: Sun Apr 01, 2012 9:23 pm

Re: 1st Edition Errata

Postby johnhook » Sun Apr 01, 2012 11:05 pm

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...
johnhook
 
Posts: 5
Joined: Sun Apr 01, 2012 9:23 pm

Re: 1st Edition Errata

Postby geo3rge » Mon Apr 09, 2012 8:08 am

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 (<condition>) {
<body>
}

and some prefer

if (condition)
{
<body>
}

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.
geo3rge
 
Posts: 4
Joined: Sun Apr 01, 2012 4:00 pm

Re: 1st Edition Errata

Postby johnhook » Mon Apr 09, 2012 11:58 pm

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
johnhook
 
Posts: 5
Joined: Sun Apr 01, 2012 9:23 pm

Re: 1st Edition Errata

Postby alexxiaa » Mon Apr 16, 2012 11:04 am

@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
alexxiaa
 
Posts: 1
Joined: Mon Apr 16, 2012 10:57 am

Re: 1st Edition Errata

Postby coonsie » Thu Apr 26, 2012 9:22 pm

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
coonsie
 
Posts: 1
Joined: Thu Apr 26, 2012 9:19 pm

Re: 1st Edition Errata

Postby MikeyWard » Tue May 08, 2012 3:26 pm

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
MikeyWard
Site Admin
 
Posts: 179
Joined: Thu May 13, 2010 10:06 pm

Next

Return to General Book Discussion

Who is online

Users browsing this forum: No registered users and 2 guests