Errata

Cocoa and Objective-C: Up and Running

Errata for Cocoa and Objective-C: Up and Running

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
ch 10.4
code example 10-6

soureWidth

should probably be

sourceWidth

Martin Baker  Apr 29, 2010 
Other Digital Version chapter 3
below figure 3.2

The array in the text has '38', whereas the figure has '48'.

David McCormick  Nov 30, 2010 
Printed Page 1
1


I was discouraged to find that there are no 'confirmed errata' when there are quite a number of reported errata.

I'm surprised that O'Reilly does not insist that their authors and editors follow-up on things that their readers take the time to report. Even unconfirmed errata deserve a comment from them.

I was hoping to find an answer to a problem I have with this book - but what's the point in reporting it if it's going to be ignored?

I guess we'll find out if anyone at O'Reilly is paying attention to this part of their website.

Thank you.

Ken McNamara  Jan 04, 2011 
PDF Page 3
2nd paragraph starting with "Safari offers a solution ..."

The last sentence of this paragraph reads "Try it for free at http://my.safaribookLsonilicne.com." Althoug the URL is linked obviously to the same URL as stated, yet it points to "http://my.safaribookLsonilicne.com." which does not resolve properly. This error can be reproduced even after quitting the Preview app and re-opening the "Rough Cuts" PDF.

My system: Mac OS X 10.6.1 using Preview and Safari (of course).

Best,

Hendrik.

Hendrik Runte  Sep 28, 2009 
7.8.1
before code example

"Heres?s the result in the console:"

should be

"Here?s the result in the console:"

Anonymous  Apr 20, 2010 
8.5.1
@protocol code listing

I couldn't get this example project to work and there's no downloadable example code to compare with. It's not at all clear whether the code listed in 8.5.1 should be entered and if it should, then where.

Martin Baker  Apr 23, 2010 
Other Digital Version 16
Chapter 8, example, (iPhone version) pag 16/26

Can't get the example working.
I get this error,

GuestBook[1776:a0f] *** Illegal NSTableView data source (<GuestBookAppDelegate: 0x10014e3b0>). Must implement numberOfRowsInTableView: and tableView:objectValueForTableColumn:row:

and I don't understand how to fix it. The Example source is incomplete, I think, and no downloadable version is available.

Pier Paolo Biagi  May 12, 2010 
Printed Page 34
near bottom (approx 5th paragraph)

Re: scope, you mention global variables are declared outside any function and local variables are declared inside a function. Then you mentioned the example of a variable declared in the main() function.

I was not clear what the scope is of a variable declared inside the main() function vs. a global variable? Does this variable have the equivalent of a global variable?

Thanks!

Roger  Jan 16, 2011 
49
Line 1

It should be pointed out that the program listed on this page will not work unless stdlib.h is included.

Anonymous  Nov 11, 2009 
52
2nd code block

In order to print only the list of names entered after the file name, the code should read:

printf( "%s\n", inputValues[i+1] );

instead of:

printf( "%s\n", inputValues[i] );

Anonymous  Nov 11, 2009 
Printed Page 63
createSong

Isn't the function createSong returning a pointer to mySong (the local instance of the Song struct)? And isn't that memory for the local variable instances created on the stack (which is release as soon as the function call returns)? Perhaps I'm wrong but I didn't think you could pass a struct by value in C. Don't have my K&R book handy but will check it later today.

Anonymous  Dec 07, 2011 
Printed Page 64
Last paragraph

Today:
This header file contains the declarations for two functions we're going use in the program.
Change to:
This header file contains the declarations for two functions we're going to use in the program.

Anonymous  Jul 26, 2011 
67
Example 3-4

Even though it is automatically generated, it seems inconsistent and confusing to not show the

#include "Song.h"

line at the top of this code listing.

Anonymous  Apr 02, 2010 
67
Example 3-5

#include "Song.h"
isn't required here since it's already included in Song.c

Ironically at the end of the page, there's a warning about multiple includes:

"If you do see this, you might have duplicate #include statements. Check your code to make sure you?re not using including Song.h more than once"

Anonymous  Apr 02, 2010 
PDF Page 67
After 2nd paragraph

Example 3-5 contains
#include "Song.h"

and should be
#include "Song.c"

Anonymous  May 18, 2011 
PDF Page 68
on C code

There is an error in the code from final example on Chapter 3. It returns this error when I compile:

gcc FinalProgram.c MathFunctions.c -o FinalProgram
Undefined symbols:
"_createSong", referenced from:
_main in ccD3CHcd.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

The same error when I use the file version downloaded from your site.

Tanks in advance,

Enric Izquierdo

Enric Izquierdo  Apr 24, 2010 
Printed, PDF Page 68
2nd paragraph

My question has to do with the author's warning ( page 68 ) that two error codes may appear as a result of compiling the Song Struct example ( files: Song.c and SongTest.c ) if file Song.h is #include'd more than once.

Anonymous, in 'Unconfirmed Errata', dated April 2, 2010, Location: page 67, example 3-5, notes:

#include "Song.h"
isn't required here since it's already included in Song.c

Ironically at the end of the page, there's a warning about multiple includes:

"If you do see this, you might have duplicate #include statements. Check your code to make sure you're not including Song.h more than once." End Anonymous

I have my own irony to add to Anonymous'. I compiled three variations of the Song Struct example ( which begins on page 66 ):
1. as it appears in the book/PDF ( with duplicated Song.h #include's ),
2. with Song.h included in Song.c but not SongTest.c and
3. with Song.h included in SongTest.c but not Song.c.

The only version that compiled without error was the first variation, that is, the one taken directly from the book/PDF which does, in fact, have duplicated #include's of Song.h.

Note: I am running OS X 10.6.6, Xcode 3.2.5 and (i686-apple-darwin10-)gcc-4.2.1

Error Messages from variation 2.:
Drews-iMac:ch03 drew$ gcc SongTest.c Song.c -o SongTest
SongTest.c: In function ?main?:
SongTest.c:16: error: ?Song? undeclared (first use in this function)
SongTest.c:16: error: (Each undeclared identifier is reported only once
SongTest.c:16: error: for each function it appears in.)
SongTest.c:16: error: expected ?;? before ?allSongs?
SongTest.c:17: error: ?allSongs? undeclared (first use in this function)

Error Messages from variation 3.:
Drews-iMac:ch03 drew$ gcc SongTest.c Song.c -o SongTest
Song.c:14: error: expected ?=?, ?,?, ?;?, ?asm? or ?__attribute__? before ?createSong?
Song.c:24: error: expected ?)? before ?theSong?

Therefore, my question is, to what form of multiple #include statements does the author refer on page 68? My experiment suggests that he is not referring to the duplicated #include statements in the Song Struct example since, at least with my implementation, the example will not run without the duplication. Can the author shed any light on this apparent paradox? Please. :-)

Drew  Jan 19, 2011 
PDF Page 68
Second paragraph of Final Example section

"Nearly of the conventions used here were described earlier in the book."

should be

"Nearly all of the conventions used here were described earlier in the book."

the word "all" is missing.

Anonymous  May 18, 2011 
Printed Page 69
main() int randomNumber

the variable randomNumber is not being use in the rest of the program, is it ?

Alex Gat  Jun 11, 2010 
Printed Page 91
3rd paragraph

Nonstandard syntax is presented: +[NSString string] and -[object release] are not explained. Are these the author's own shorthand for something? -- these constructs, "+" or "-" preceding a message passing call are not contained in Apple's documentation, as far as I can tell.

Anonymous  Sep 02, 2011 
PDF Page 94
3rd paragraph

In the paragraph:

Although it looks like an advanced trick, this is the standard way to write an init method. I'll usually discourage you from combining two separate actions into one be- cause it can be confusing, but this one is so common that it the standard.

The last sentence is missing an "is" before "the standard": "I'll usually discourage you from combining two separate actions into one be- cause it can be confusing, but this one is so common that it is the standard."

James Frye  Nov 08, 2009 
94
Top (in the callout box)

This one is a minor grammar quibble: the use of the past tense where the subjunctive mood would be correct. Here's the original:

"If that was true, and you were to -release the caption object, it could immediately be freed and the next line of code would crash the application."

That "was" should be a "were," since you're supposing something contrary to fact. It's odd, in fact, that it's correct in the second clause of the sentence but not in the first one. Both should be in subjunctive mood, though, as both conditions are contrary to fact.

jamesnotjim  Jun 27, 2010 
PDF Page 100
2nd paragraph

The first sentence should say "Properties are not methods." instead of "Property are not methods."

James Frye  Nov 08, 2009 
PDF Page 109
NSUInteger tip

"The NSUInteger simply a way to store unsigned integer values for both 64-bit and 32-bit systems. See the section ?Cocoa-Specific Primitive Types? later in the chapter for a more detailed explanation."

should say

"The NSUInteger is simply a way to store unsigned integer values for both 64-bit and 32-bit systems. See the section ?Cocoa-Specific Primitive Types? later in the chapter for a more detailed explanation."

James Frye  Nov 08, 2009 
Printed Page 138-139
the comment on Page 139

in the comment on Page 139:

"// BEST: when reusing a variable, use a class method"

I check NSString.h in SDK,

it is" -stringByAppendingString ", so it is not a class method.


Meanwhile, in the middle of Page 138, before Table 7-1

"The +stringByAppendingString:, -initWithString:, "

should be:

"The -stringByAppendingString:, -initWithString:, "

In the bottom of Page 137,

"+stringByAppendingString: returns an autoreleased object."

should be:

"-stringByAppendingString: returns an autoreleased object."


Wei Yuemin  Dec 20, 2011 
Printed Page 138-139
in the middle of Page 139

In the middle of Page 138, before Table 7-1

"The +stringByAppendingString:, -initWithString:, "

should be:

"The -stringByAppendingString:, -initWithString:, "
(I check NSString.h in SDK, it is" -stringByAppendingString ")

Meanwhile,
In the bottom of Page 137,

"+stringByAppendingString: returns an autoreleased object."

should be:

"-stringByAppendingString: returns an autoreleased object."


Wei Yuemin  Dec 20, 2011 
Printed Page 199
step 4

Interface Builder does not recognize that ApplicationAppDelegate has a buttonClick method until it's precompiled; therefore, Control-dragging from the button to the ApplicationAppDelegate icon does not cause a window to pop-up (until you go back and precompile).

Steve Poirot  May 23, 2010 
PDF Page 199
Item # 2

Item 2 says:
"In Xcode, expand the Classes folder, open the ApplicationAppDelegate.h interface
file, and add the following line just below the @property declaration for the window.
This is the action method:
@interface ApplicationAppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
- (IBAction) buttonClicked:(id)sender;
@end"

When I start a new Xcode Cocoa application it doesn't have any entries in the Classes Folder.

The 'ApplicationAppDelegate.h' and '.m' files don't exist.

I tried doing a compile to see if they were somehow generated - but that didn't change it.

This is probably an Xcode change that you have no control over - but I'd like to follow the book if possible.

Thank you.

Ken McNamara  Jan 11, 2011 
Printed Page 248

Can Gallery_AppDelegate.m be provided in the ch10.zip please?

Cheers,
Captain Fatty

Matthew Whillock  Sep 12, 2010 
260
1st para

"Add a relationship to Album called photos. This time, leave the Optional checkbox enabled."

But the screenshot 9.16 has the optional unchecked which feels correct since it was not optional for the complimentary relationship of album to Photo.

Martin Baker  Apr 26, 2010 
Other Digital Version 260
Update the App Delegate

There are a couple of errors with the Gallery Example which is Chapter 9 in my book, but Chapter 10 of the downloaded sample code files. The sample code files do not contain Gallery_AppDelegate.m.

The error is that the book instructs you to put the following line in the implementation file:

@synthesize mainWindow;

However, that property is not defined in the Gallery_AppDelegate.h file nor do I see that it is actually used anywhere in the code. I omitted it and it seems to work fine.

Also, two new properties are defined with retain in the Gallery_AppDelegate.h file: mainWindowController and selectedAlbum. I assume these need to be released in dealloc or set to nil, but there are no instructions in the example to add any lines to the template provided dealloc method.

Mike Ruch  May 09, 2011 
Printed Page 262
@synthesize mainWindow;

Chpater 9: sample project does work.
Compile Error: "mainWindow" not defined.

The line "@synthesize mainWindow;" seems not necessary.
The project compiles if I declare the "mainWindow" property in its
header file or comment out the line in the implementation file(.m file.)

Anonymous  Jul 19, 2010 
Printed Page 262
11th line of code (including comment)

The line of code in the Gallery_AppDelegate.m file reads:

@synthesize mainWindow;

The corresponding property does not appear in the .h template code provided by Xcode (version 4.0). Commenting out the line lets the code compile but the program does not behave as expected (I've probably missed out a step connecting an outlet or got the bindings wrong). Should there be a mainWindow property in the app delegate?

Also on page 263, Xcode 4.0 generates this:

@property (assign) IBOutlet NSWindow *window;

instead of:

@property (nonatomic, retain) IBOutlet NSWindow *window;

Cheers,
Captain Fatty

Matthew Whillock  Sep 12, 2010 
PDF Page 262
1st half of page

On page 262 in the tutorial for creating the Gallery application the author references making a change to the -applicationSupportDirectory: method in Gallery_AppDelegate.m,

The method does not exist in the Gallery_AppDelegate.m

This is pretty annoying and a pretty big error as I am unsure how to continue with the tutorial.

Jeff Uren  Mar 26, 2011 
Printed Page 262
Code to add to Gallery_AppDelegate.h

As others have stated, the app will not run because of the line @synthesize mainWindow. I added:
@property (retain) CBMainWindow* mainWindow;
to the Gallery_AppDelegate.h file and it runs.
Two other problems I can not find solutions to are
1) the largeThumbnails in the list view are not large and
2) the default album will not load. I can, however, make a new Album using the menu and place photos in it.

George Thompson  Jan 13, 2013 
263
code example 9-1

App running fails with error:

error: no declaration of property 'mainWindow' found in the interface

Martin Baker  Apr 27, 2010 
PDF Page 282
Method awakeFromInsert

The Apple documentation on the method awakeFromInsert (inherited from NSManagedObject) strongly recommends that the super method be called first in the overridden version.

So the code should read:

- (void) awakeFromInsert {
// called when the object is first created.
[super awakeFromInsert];
[self generateUniqueID];
}

See:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObject_Class/Reference/NSManagedObject.html

Jeremy Wilson  Oct 29, 2010 
Printed Page 301
RUN THE APPLICATION

Gallery application

no declaration of property 'mainWindow' found in interface.

What's the answer to this?
It's been asked several times here.
Thanks much.

AndyElliott  Sep 28, 2010 
Printed Page 339
Code at page bottom

The shadow does not appear if the code is entered as written in the book. The second if statement in the -setShouldAddShadow method should check the value of the 'shouldAdd' parameter passed to it, not the value of the 'shouldAddShadow' variable, as written.

Clay  Aug 17, 2010 
Printed Page 339
Code at page bottom

Please ignore the previous mention of the code problem. I missed a line. Thanks.

Clay  Aug 17, 2010