Home - Author Bios - Table of Contents - Downloads - Errata   

Errata

We welcome comments and corrections to this title.

Cocoa Programming has had the benefit of review by three authors, two technical reviewers, and five editors using an extensive formal review process. Nevertheless, we are sure that mistakes have been made and improvements are possible.

Please feel free to send suggestions and corrections to comments@cocoaprogramming.net. We will incorporate reader feedback as much as possible in future editions.

One of the pleasures of developing software with Cocoa has always been the community surrounding the technology, and one reason we wrote this book was to contribute to that community. With your help, we can produce an even better book in the future.

Current Errata

Code Examples in the book

In every code example, the C post decrement operator -- has been replaced with an [em] dash in printed source code. The page layout software used by the publisher probably did this and nobody noticed.

For example: See page 1127

- (void)dealloc
/*" Clean-up "*/
{
  _MYTotalNumberOfInstances-;
  [super dealloc];
}
@end

which should be


- (void)dealloc
/*" Clean-up "*/
{
  _MYTotalNumberOfInstances--;
  [super dealloc];
}
@end

The downloaded code examples are correct.

Chapter 4- Objective-C

Page 69

Paragraph 3

"The syntax for sending a distributed message is exactly the same as the stntax for local messages."

it should read

"The syntax for sending a distributed message is exactly the same as the syntax for local messages."

Page 77

In the example code on page 77, the method name

 -avarageValue; 

should be

 -averageValue;

Page 78

The first sentence is

..."values is returned from the -average method."

it should be

..."values is returned from the -averageValue method."

Page 78

In the example code on page 78, the method name

 -(float)avarageValue; 

should be

 -(float)averageValue;

Page 78

The implementation of -setValue:atIndex: is

-(void)setValue:(float)aValue atIndex:(int)anIndex
{
    // set the value with the specified index
  if (anIndex>= 0 && anIndex<10) {
     _myValueArray[i]=aValue;
     }
 }
 

it should be

-(void)setValue:(float)aValue atIndex:(int)anIndex
{
    // set the value with the specified index
  if (anIndex>= 0 && anIndex<10) {
     _myValueArray[anIndex]=aValue;
     }
 }
 

Chapter 5 - Conventions

Page 117

In the second code example, the method name retain has been mislabeled as reatin. The corrected source is listed below.

- (id)initWithCoder:(NSCoder *)coder
{
   self = [super init];
   _myLabel = [[coder decodeObject] retain];
   _myLabelFont = [[coder decodeObject] retain];
   [coder decodeValueOfObjCType:@encode(NSPoint) 
                             at:&_myLabelPosition];
   _myExtraData = [[coder decodeObject] retain];
   [coder decodeValueOfObjCType:@encode(float)
                             at:&_myLineWidth];
   _myStyles = [[coder decodeObject] retain];
   _myColor = [[coder decodeObject] retain];
   return self;
}

Chapter 7- Foundation Framework Overview

Page 150

The implementation of MYSimpleClass is incorrect. The following code is corrected.

@interface MYSimpleClass
{
    NSMutableString *_myStringValue;
}

- (NSString *)safeStringValue1;
- (NSMutableString *)safeStringValue2;
}

@implementation MYSimpleClass


- (NSString *)safeStringValue1
{
     // The instance variable can be safely returned.
     // The caller will have to cast the return value
     // to violate MYSimpleClass’s encapsulation
     return _myStringValue;
}

- (NSMutableString *)safeStringValue2
{
     // A mutable copy of the instance variable is returned
     return [[_myStringValue mutableCopy] autorelease];
}
@end

 

Chapter 9 - Applications, Windows and Screens

Page 235-236

The implementation of _mySetDocumentPath: reads the following (top of page 236)

_myDocumentPath = aPath;

it should in fact read

_myDocumentPath = standardPath;

This has been corrected in the example code available for download.

Chapter 16 - Menus

Page 634

The first paragraph, second sentence reads

"The dictionary contains a single key, @"NSMenuItem", which returns the NSMenuItem that has been selected."

it should read

"The dictionary contains a single key, @"MenuItem", which returns the NSMenuItem that has been selected."

Chapter 20 - Apple Help

Page 793-794

It is not necessary to change the file type and creator before indexing help files as is stated on these pages.

Chapter 25 - Printing

Page 954

Figure 25-7 shows the incorrect images for Pages 2 and 4. A corrected PDF of the image is available.

Page 957

Figure 25-8 shows the incorrect images for Pages 2 and 4. A corrected PDF of the image is available.

Chapter 26 - Application Requirements, Design and Documentation

Page 969

The figure is incorrectly cropped. The caption says "TransparentTetris is implemented with the two windows shown." Only one of the windows is shown
in the figure. See correct figure below:

Appendix A - Unleashing the Objective-C Runtime

Page 1075

In the Common Runtime Functions section, the first piece of example code is incorrect, it reads

NSLog(@"%@",NSStringForSelector(_cmd));

instead, it should read

NSLog(@"%@",NSStringFromSelector(_cmd));
"Visit Stepwise"
Copyright 2002 - Scott Anguish, all rights reserved.