2nd Edition Errata


#1

Here are the known errata for the book. Each item is notated affecting either the eBooks, the printed books, or both.

Page 62: (print only)
missing import:

#import <stdio.h> #import <readline/readline.h> // missing this import int main(int argc, const char * argv[]) { printf("Who is cool? "); const char *name = readline(NULL); printf("%s is cool!\n\n",name); return 0; }

Page 74: (print/ebook)

metersToFeedAndInches() should be metersToFeetAndInches().

Page 107:

NSString listOfNames = @"..."; // a long list of names NSString name = @"Ward"; NSRange match = [listOfNames rangeOfString:name];

should be

NSString *listOfNames = @"..."; // a long list of names NSString *name = @"Ward"; NSRange match = [listOfNames rangeOfString:name];

(asterisks were missing)

Page 121: (print/ebook)

“To find out what the count method does, you should go to NSDate’s class reference page.” Should refer to “NSArray’s class reference page.”

Page 148: (print/ebook)

“This challenge builds on the challenge from the previous chapter.” Actually, it builds on the challenge from chapter 18, two chapters ago.

Page 181: (print/ebook)

should be

Page 202: (print/ebook)

“o You can also create an instance of…” Spurious “o” at the beginning.

Page 211-212: (print only)

incomingData, being an instance variable, should be underscored throughout this exercise (to appear as _incomingData). For bonus points, it should be declared and accessed as a property rather than an instance variable.

Page 286: (print only)

wrong method names:

[code]@interface BNROwnedAppliance : BNRAppliance
@property (readonly) NSSet *ownerNames;

  • (instancetype)initWithProductName:(NSString *)pn
    firstOwnerName:(NSString *)n;
  • (void)addOwnerNamesObject:(NSString *)n; // should be addOwnerName:
  • (void)removeOwnerNamesObject:(NSString *)n; // should be removeOwnerName:
    @end[/code]

Page 287: (print only)

missing @end:

@interface BNROwnedAppliance () { NSMutableSet *_ownerNames; } @end // this was missing

Page 295: (print only)

missing Mushroom* in property and too many colons in setter name:

[code]@interface Badger : NSObject ()
@property (nonatomic) mushroom; // Should be “@property (nonatomic) Mushroom *mushroom;”
@end

@implementation Badger;
@synthesize mushroom = _mushroom;

  • (Mushroom *)mushroom
    {
    return _mushroom;
    }

  • (void)setMushroom::(Mushroom *)mush // too many colons
    {
    _mushroom = mush;
    }[/code]


#2

The Coolness project (Chapter 8) starts out with #include <studio.h> (throughout the chapter), but when you get to the challenge, it becomes #import <studio.h>
without being pointed out that it is changed. If I recall correctly, the difference between include and import are discussed later in the book.


#3

The page numbers that refer to the errata entries aren’t consistent across platforms e.g. the iBooks version is different. It would be helpful to include chapter and section names.


#4

In the ebook, there is a problem with the break example in chapter 8: Loops.

I believe the code should read:

[code]
#include <stdio.h>

int main(int argc, const char * argv[])
{
for (int i = 0; i < 12; i++) {
printf(“Checking i = %d\n”, i);
if (i + 90 == i * i) {
printf(“The answer is %d.\n”, i);
break;
}
}

return 0;

}[/code]

Using the code provided in the book’s example will result the last output statement being:

The answer is 0.

Rather than what should print out:

The answer is 10.


#5

In chapter 27 (e-book) you will find the following statement:

    [[NSNotificationCenter defaultCenter] addObserver:logger
                                             selector:@selector([color=#0000FF]zoneChange:[/color])
                                                 name:NSSystemTimeZoneDidChangeNotification
                                               object:nil];

The zoneChange selector does not seem to exist, when I run the code straight from the book I get an ‘unrecognized selector’ exception. When I change the selector to ‘timeZone’ and add the method to BNRLogger.m the code runs fine.

EDIT: I am wrong here. When I add the method definition of zoneChange in BNRLogger.h, the code works fine. So my guess is that that should be added to the text.
Apologize!


#6

p. 135 “Use properties to create accessor methods and instance variables.” These are not introduced until the next Chapter.

p. 141 “Your BNREmployee class adds two BNREmployee-specific characteristics - an employee ID and a hire date.” Actually three if you include the officeAlarmCode.

p. 153 “You are going to create an BNRAsset class,…” replace “an” with “a”

p. 158-159 In order to match the output on p. 159, you have to have to remove the “350 +” on p. 158

p. 167 addAsset: “if (!_assets)” and “_assets = [[NSMutableArray alloc] init]” note the underscore (not in book). Otherwise I get an error "Use of undeclared identifier ‘assets’; did you mean ‘_assets’?

p. 179 When we change from array to set, we should probably also change the accessors to NSSet (originate on p. 156)

p. 287 if (self = [super initWithProductName:pn]) { (note the missing “{”)


#7

[quote=“MikeyWard”]Here are the known errata for the book. Each item is notated affecting either the eBooks, the printed books, or both.
[…]
Page 107:

NSString listOfNames = @"..."; // a long list of names NSString name = @"Ward"; NSRange match = [listOfNames rangeOfString:name];
should be

NSString *listOfNames = @"..."; // a long list of names NSString *name = @"Ward"; NSRange match = [listOfNames rangeOfString:name];
(asterisks were missing) […][/quote]

This was page 115 In the book. :wink:


#8

In the print edition, p. 167: In the modified addAsset method at the top of the page, I believe the instance variable in 3 places should be _assets instead of assets.

Cheers,

Joe


#9

[quote=“ericbishop”]In the ebook, there is a problem with the break example in chapter 8: Loops.

I believe the code should read:

[code]
#include <stdio.h>

int main(int argc, const char * argv[])
{
for (int i = 0; i < 12; i++) {
printf(“Checking i = %d\n”, i);
if (i + 90 == i * i) {
printf(“The answer is %d.\n”, i);
break;
}
}

return 0;

}[/code]

Using the code provided in the book’s example will result the last output statement being:

The answer is 0.

Rather than what should print out:

The answer is 10.[/quote]

I think the authors specifically declare the i integer outside the for loop, which allows the printf function to call it at the end of the loop. It’s not called out well that they changed the code from the code in the for loop section.

Your code works because you retain the i declaration within the loop.


#10

I have looked around a bit, and have enabled Amazon’s “auto-update books” option that now exists, but I have a slightly different question:

I assume that you push errata to Amazon for updating electronic versions of books. What kind of timeframe is associated with this? If, for instance, you pushed a change to Amazon today, when would Kindle eBook owners see an update? This would help me in determining if I need to go through an eBook and make note of changes, or, if we’re six weeks down the line and Amazon has published the changes, I can safely assume that the book is current to that point.

Thanks!


#11

Looking at the print edition on page 252, the comment at the top of the page does not match the code given at page 247. To match the earlier version, the words “table view” should be changed to “UITableView instance”


#12

On page 324 in Chapter 40 C Arrays:

The averageFloats function code block is shown here in bold. It is repeated here for the second time from the previous page with no edits, so the font weight should not be bold, per the book’s convention.

On page 341 in the Appendix A. The Objective-C Runtime:

The first comment block has a repeated ‘an’

Near the bottom of the code block, in the NSSortDescriptor init, the key should be @“classname”, not @“name”, so that the sort works properly. It does not work as shown:


#13

In the ebook, there is a problem with code example in chapter 31: «Your First iOS Application», section «Wiring up the table view»

The book say:

    // To improve performance, this method first checks
    // for an existing cell object that we can reuse
    // If there isn't one, then a new cell is created
    UITableViewCell *c = [self.taskTable dequeueReusableCellWithIdentifier:@"Cell"];

    // Then we (re)configure the cell based on the model object,
    // in this case the tasks array, ...
    NSString *item = [self.tasks objectAtIndex:indexPath.row];
    c.textLabel.text = item;

where it should say:

//To improve performance, this method first checks //for an existing cell object that we can reuse //if there isn't one, then a new cell is created UITableViewCell *c = [self.taskTable dequeueReusableCellWithIdentifier:@"Cell"]; if (!c) { c = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; } //Then we (re)configure the cell based on the model object, //in this case the tasks array,... NSString *item = [self.tasks objectAtIndex:indexPath.row]; c.textLabel.text = item;


#14

[quote=“MikeyWard”]Here are the known errata for the book. Each item is notated affecting either the eBooks, the printed books, or both.

Page 62: (print only)
missing import:

#import <stdio.h> #import <readline/readline.h> // missing this import int main(int argc, const char * argv[]) { printf("Who is cool? "); const char *name = readline(NULL); printf("%s is cool!\n\n",name); return 0; }

[/quote]

Despite this correction, I still have issues. While typing my name, each character I type is echoed immediately after typing it. Example:

[code]
Who is cool? WWiicckkeedd

Wicked is cool![/code]

So when i press the W key once, it produces two Ws on the screen, and so on.

Edit: later in the book it describes this as expected behavior. So this is nothing the fret about.


#15

In the book on page 144, in the second to last NSLog command, the token for mikey.employeeID is given as %lu. Xcode gives a warning to use %u instead of %lu. employeeID is of type unsigned int.


#16

On the first page of chapter 9 in the print version, just below fig. 9.1, it says,

“When people talk about a 32-bit CPU or 64-bit CPU, they are usually talking about how big the address is”.

While this may be the authors’ perception, it is incorrect. The 32-bit or 64-bit refers to the width of the CPU’s internal data bus or the width of the ALU - NOT the width of the address bus. The width of the address bus on many modern 32-bit machines is, in fact, wider than 32 bits.


#17

On pages 166, 173, the variable holder is used a few times. I think it needs to be either _holder or someAsset.holder in all of those cases. On page 167, we do see a.holder where a is an asset.


#18

p. 209 Helper objects

In figure 27.2 the BNRLogger the following method is wrong: -connectionDidFinishLaunching:
it should be: -conectionDidFinishLoading.
(this is then correctly being used on p212 where the code is outlined)


#19

Page 135 (Book)

In the Challenge section it mentions two floats names _purchaseSharePrice and _currentSharePrice. In the Figure18.4 it then uses floats named _purchasePrice and _currentPrice.


#20

Page 142 (Book) Chapter 20 Inheritance

It says, “change the superclass from NSObject to BNRPerson:

It shouldn’t have the colon at the end. “change the superclass from NSObject to BNRPerson