Learning Cocoa with Objective-C by Apple Computer, Inc., James Davidson This errata page lists errors outstanding in the most recent printing. If you have technical questions or error reports, you can send them to booktech@oreilly.com. Please specify the printing date of your copy. This page was updated March 22, 2007. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification Confirmed errors: Note: some readers report having trouble compiling the example code from the book with gcc 3.3, but they work fine with gcc 3.1 (xxii) 1st para; Illona is spelled Ilona (one 'l' character instead of two) (xxi), acknowledgements, para 3 Glenn Vanderburg should also be acknowledged for helping tech review the book. (7) 2nd paragraph; Should be "embedded" instead of "embedding" in "...according to any color profile embedding in the image along with profiles for the display or printer." should be: "...according to any color profile embedded in the image along with profiles for the display or printer." (12) Figure 1-3, 1st box; Should be "Data and values" instead of "Data values" (28), line -3 (third from bottom): import should be #import (29), bottom note pul-down should be spelled pull-down. (34), line -2 "tht" should be "that" (42) The link in Exercise #3 no longer exists. Some of that information can be found here - http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/Documentation.html (48) Everywhere; In the example code, there are typos relaed to case sensitivity. The string "NSAutoReleasepool" is not correct. It should be "NSAutoreleasePool". {52} third line of first paragraph; In Figure 3-6, there is an extranneous space after the argument width. (52): 2/3 way down the page: "Note that setWidth:height: refers to one method, not two. It will call a method with two arguments. When using this method, you must pass in two arguments, labeled and formatted as in Figure 3-6." It should say: "...Figure 3-7." (62) Final paragraph recommends return parameter be changed back to "[self description]" should say: return parameter be changed back to "[self name]" {65} Example 3-9; Ending bracket following "return self; //F" is not bolded (66) 1st paragraph; In the continued code for example 3-9 "return [super description]" should be "return [self name]" {71}, para 3 The statment that they are limited to 7-bit ASCII strings is wrong. It seems that 8-bit values, such as ) and a can be placed into @"String" statements with no ill effects. There does seem to be a little bit of interesting interaction with some transformations from one kind of string representation to another, and it may be that 7-bit ASCII is the safe bet, but it's not apparently the only bet anymore. (71) para 3; To fix 7-bit ASCII problem, just the text "7-bit" should be ommitted. (77) step 2 code sample; Line C -- remove space between @ and " symbols. IE, the line should read: NSRange range = [song rangeOfString:@","]; (79) line -13: "forr" should be "for" {79} first line of step 2i; "Song" should be "song {85} line 2; For step 5, there should not be a semicolon at the end of the command to gdb. (92)line -9: "follos" should be "follows" (93) Example 4-6; One of the array objects is "Pheonix" instead of "Phoenix". {93} Step 2.f.; It says "Returns the array" instead of "Releases the array". (117) Step 4 of "Test the Interface"; It should say "to exit the test mode" rather than "to exit the text mode". {118} Figure 5-21; The Converter class already appears in the list although it will be created only later. This confused me for a few minutes, as I had to browse back until the beginning of the chapter to see where I should have created it. AUTHOR: Yes, the figure illustrates the Converter the page before it's created, but the page is across the gutter from it. Maybe we could do something like change the caption to read: Figure 5-21. Creating the Controller and Converter classes and defining the outlets. (128) 1st paragraph under NSView; "Any object you see in a widow's content area...". should be: "Any object you see in a window's content area...". (128) 2nd from last paragraph; Missing comma after "around" in "The frame can be moved around resized, and rotated in the superview." it should be: "The frame can be moved around, resized, and rotated in the superview." (128) last paragraph; Should be "of" instead of "if" in "...or one if its variants." it should say: "...or one of its variants." {150} Example 6-3; The refresh method appears below the awakeFromNib method but if file merge was performed according to the instructions on the previous page, it should appear above. AUTHOR: Confirmed. The fix will be to swap the order of the methods in Example 6-3 so that the codeblock reads: -------------------------------------------------- #import "MyController.h" @implementation MyController - (IBAction) refresh:(id)sender { [textField setObjectValue:[NSCalendarDate date]]; <<<< BOLD } - (void) awakeFromNib { [textField setObjectValue:[NSCalendarDate date]]; } @end -------------------------------------------------- (150) Step 1; Drop the word "nib", since we are saving MyController.m here. "Save the changes to the nib file" should say: "Save the changes to the file" (164) only non-code paragraph; "creates a oval path" should say "creates an oval path" Page 171 Figure 8-4, right picture, "DotView Class Info": Outlet Name = colorWell, Type = NSColorWell should be highlighted, not slider, NSSlider. {174} Top of Example 8-2; Looks like the latest version of Interface Builder automatically inserts the initWithFrame method, along with the first and last statements (and they use a different parameter name: frame -> frameRect). AUTHOR: There has been a minor change in the PB templates. (176), in example 8-6, the following is written: // Define the size the dot The comment should be written: // Define the size of the dot (179) Paragraph under "Implement the setRadius: action method"; In the second line, "send" should be "sender" - the sentence should read "This method assumes that the sender is a control capable of returning a floating-point number." {183} Table 8-1; The second parameter should be named "message" rather than "Msg" to coincide with the signature of the function that is given above the table. {186} Table 8-2; As in Table 8-1, the Parameters should mattch the function signature provided. The xxxButton parameters need to be xxxButtonLabel, and msg should be message. [186] Table 8-2; The descriptions for the alternateButton and otherButton parameters are wrong. In addition, the description for the defaultButton could use a little clarification. These should read: defaultButton -- The label for the sheet's default button that appears in the rightmost position, typically "OK". alternateButton -- The label for the sheet's alternate button that appears at the leftmost position. If you pass nil, the button will not be created. otherButton -- The lable for sheet's other button that appears between the default and alternate buttons. Typically, this is the button used for "Cancel" or "NO". If you pass nil, the button will not be created. {196}, step 3 code block The aName and aPrice variables should be newName and newPrice respectively to match later code. The FoodItem.h file should look like this: #import @interface FoodItem : NSObject { NSString * name; NSNumber * price; } - (NSString *)name; - (void)setName:(NSString *)newName; - (NSNumber *)price; - (void)setPrice:(NSNumber *)newPrice; @end {197}, step 4 code block, setName: method There is a missing semicolon in the [name release]; statement. (203) final paragraph, 3 lines from the end of the page; Directory name should be 'keyvaluecoding' not 'Key View Coding' {208}, step 8 The action method is erroneously labled newActionPressed:. Step 8 should read: Control-drag a connection between the New Item button and the MyDataSource object in the Instances tab. Connect it to the newButtonPressed: action, as shown in Figure 9-12. (210) line -12 (item 1, line 2): "the Song class" should be "the FoodItem class" <223> IN PRINT: "The Document Object" section, first bulleted item; SHOULD BE: "Provide a data representation of the document to other objects in the application. The document object must be able to provide the data in any of the formats supported by the application." {228} Examine the Document Interface - 2nd para; " ... you'll notice in the Attributes pane that File's Owner is set to correspond to an instance of MyDocument." 'Attributes' should be 'Custom Class' as 'Attributes' says 'not applicable'. (235), step 3, code block The if (dataFromFile) { line should be in boldface type to mark it as a new line of code. (236) line 6: "clicked" should be "checked" (236) last paragraph before Exercises; There's a stray "C" in "...that users expect Cfrom a text editing application." It should say: "...that users expect from a text editing application." (237) 1st line; Extraneous "the" in "In the Chapter 10, we showed how..." It should say: "In Chapter 10, we showed how..." {239} second to last paragraph; The sentence "By overloading the file wrapper load and save methods, we can support RTFD." should read "By overriding the file wrapper load and save methods, we can support RTFD." (240) Step 11; It should be "rtfData" instead of "dataFromFile" in "Open MyDocument.h, and add the dataFromFile instance variable to hold the raw RTF data loaded from a file." it should read: "Open MyDocument.h, and add the rtfData instance variable to hold the raw RTF data loaded from a file." {241}, step 13, code block In the 8th line of code, after the [[textView string] length]) statement, there are two erroneous extra characters (];). This code block should look like: if (textView) { [[textView textStorage] replaceCharactersInRange:NSMakeRange(0, [[textView string] length]) withAttributedString:rtfData]; [rtfData release]; } {242}, step 14, code block There is a missing end parenthesis at the end of line 3. This line should look like: NSRange range = NSMakeRange(0, [[textView string] length]); {242}, step 15, code block There is an erroneous extra semicolon at the end of line 6. This code should look like: if (rtfData) { [[textView textStorage] replaceCharactersInRange:NSMakeRange(0, [[textView string] length]) withAttributedString:rtfData]; [rtfData release]; } {247} Step 1 code block; The type of the dataFromFile variable should be NSAttributedString *. The code line should read: NSAttributedString * rtfData; (255) Question 3; There was only one Speak button in the project, so it should be "Replace the Speak button with a menu item." (270) Step 3; There's no need to copy the pictures into the project's directory. This line should read: "In the next sheet that drops down, click the add button." (277) Step 2; Line 12 of code sample is missing a ";". Code should read: "[image release];" {303} Figure 16-8 (top of page); Figure 16-8 shows the list of classes used to set the File's Owner as being under the "Attributes" pane of the "File's Owner Info" window but it is now located under the "Custom Class" pane (Command-5). (310) 3rd paragarph, 1st sentence - ...Adobe Photoshop, use this section learn how to... Should be ...Adobe Photoshop, use this section to learn how to... {311}, step 7 The path mentioned should be ~/LearningCocoa/Dot View/DotView.icns. You shouldn't see a problem saving it to the location mentioned in the book, but you should always keep your resources with the rest of your project. (315) Tip; Extraneous "0" character before the word "information" {327-328} Step 3 code block; The pointer stars are missing in 3 of the variable declarations. This code block should read: @interface Controller: NSObject { IBOutlet id converter; IBOutlet NSTextField * dollarField; IBOutlet NSTextField * rateField; IBOutlet NSTextField * totalField; } - (IBAction)convert:(id)sender; @end {329} Exercise 8-4 Code block; The return type of the method should be NSApplicationTerminateReply instead of NSTerminationReply (329) in the section exercise solutions, #4 - (NSTerminateReply)applicationShouldTerminate:(NSApplication *)sender should be: - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender (344) line -1: replace "shear" with "sheer"