Errata

Head First iPhone Development

Errata for Head First iPhone Development

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
Printed, PDF Page XXIX
Last paragraph

In page XXIX is described XCode 3,2 as IDE, but in the page 8, XCode 3.1 is cited. What`s correct?

tks

Josivan Pereira de Souza  Dec 29, 2010 
Printed Page 23
Last para

The direction here is reversed. You need to hold the Ctrl key down and drag from the File's Owner to the label.

Gene K  Sep 11, 2010 
25
Missing From Exercise

If you compile the iDecide as is you will get the following compiler error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "iDecideViewController" nib but the view outlet was not set.'

You need to include details on connecting the view properly.

Vincent Reinhardt  Aug 11, 2010 
Printed Page 25
1st para

"Just like with outlets" seems to be incorrect. You drag the opposite direction. (See errata for p. 23) Also, the code throws an exception as provided in the book; you need to connect the File's Owner to the View itself as well.

Gene K  Sep 11, 2010 
Printed Page 76

Throughout the book, the pointer symbol (*) is sometimes next to the variable type and other time next to the variable name. While this doesn't matter to the compiler, is there a reason for this inconsistency? Does it make the code more readable to have it in certain places at certain times? I'm just wondering if there is a formatting convention I am not aware of.

Reid Mullen  Feb 01, 2010 
Printed Page 79
errata for page 79

The errata correction listed for page 79 in the
"Note from the Author or Editor:" says:
in the code, change NSLog(the message) to NSLong(@"%s", themessage);

That note has a typo. That really should be NSLog, not NSLong.

Anonymous  Oct 31, 2010 
PDF Page 79
Code snippet

Typo in authors errata correction for this page. NSLong should be NSLog

creativetags  Nov 04, 2010 
PDF Page 79
Code snippet

I'm not sure if this is right but works for me:
NSLog(@"%@", themessage);

creativetags  Nov 04, 2010 
PDF Page 79
NSLog(themessage)

NSLog(themessage) should be NSLog(@"%@", themessage")

CreativeMobility  Nov 25, 2010 
Printed Page 81
Twitter Black Magic code snippet

When compiling the code, I get a warning at line beginning with NSData* result = ... saying "NSURLConnection may not respond to +sendSynchronousRequest:returningResponse:error
and the application stops (on the iphone simulator) with the following message :

2009-12-27 18:51:43.276 Instatwit3[8648:207] *** +[NSURLConnection sendSynchronousRequest:returningRespone:error:]: unrecognized selector sent to class 0x1ac680
2009-12-27 18:51:43.277 Instatwit3[8648:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSURLConnection sendSynchronousRequest:returningRespone:error:]: unrecognized selector sent to class 0x1ac680'
2009-12-27 18:51:43.277 Instatwit3[8648:207] Stack: (
29291611,
2467292425,
29673723,
29242998,
29095618,
9113,
2720857,
3128226,
3136963,
3132175,
2825779,
2734108,
2760885,
37387985,
29076352,
29072456,
37382029,
37382226,
2764803
)

Marc Durbach  Dec 27, 2009 
PDF Page 164
first main paragraph

The error here is already raised in the "confirmed" errata list on the website, however the correction is also only partially correct.

The editors suggestion is that the word "enabled" should be changed to "editable", however this is only true for the two UITextViews mentioned. There is no "editable" checkbox for an UITextField in Interface Builder.

I suggest that "simply click on each field and toggle the enabled checkbox to off" should be written as "Click on each field and toggle the Editable checkbox to off for the two UITextViews, and the User Interaction Enabled checkbox off for the UITextField."

Cheers

Peter Johnson  Sep 06, 2010 
Printed Page 181
Last line of code.

Replace the last line of code:
[DrinkDetailViewController release];
by
[detailViewController release];

It should be the object get released not the class.

Monza Lui  Mar 13, 2012 
Printed Page 198
3rd column

Last question (valueForKey vs. objectForKey): In the sentence "The subtle catch is that NSDictionary usually just turns a call to valueForKey: into a call to objectForKey, and ..."

One time the colon is here, the other not.

valueForKey: & objectForKey: OR
valueForKey & objectForKey

Anonymous  Aug 02, 2010 
Printed Page 202
Second handwritten solution in 'Sharpen your pencil'

Answer indicates we will stick with the 'disclosure indicator' as the detail disclosure button is 'more than we need'.
The current HIG specifically states, under 'table-view elements':
"Don?t use a disclosure indicator to reveal detailed information about the list item; instead, use a detail disclosure button for this purpose."

Since we are showing detailed info about the one item selected, and not a list, should we not use the detail disclosure button rather than the disclosure indicator?

Anonymous  Jun 01, 2010 
Printed Page 202
Answer to 1st "Sharpen your pencil Solution" question

"Configuring a Table View" is outdated. Instead see "Using Table Views to Enable Common User Actions" > "Navigating hierarchical information".

See Revision History of 2009-11-20 Fixed minor errors and rearranged table view content

Anonymous  Aug 02, 2010 
Printed Page 202
Sharpen your pencil solution

This section is very confusing. Is it the indicator or the button in answer no. 2?

If I look in the current HIG, I find the following:
"Use a disclosure indicator in a row when selecting the row results in the display of another list. Don?t
use a disclosure indicator to reveal detailed information about the list item; instead, use a detail disclosure
button for this purpose."

Then it should be a button?

Anonymous  Aug 02, 2010 
Printed Page 218
Paragraph about the nib's file's owner

This sentence doesn't make sense: "The nib doesn't actually contain the ViewController class it's setup to be wired to."

Anonymous  Aug 03, 2010 
Printed Page 219
1st description text in the graphic

The arrow with the description text "By default, fields in Objective-C are protected, so we can get to them in our subclass" points to a method (and not the field nameTextField).

Anonymous  Aug 03, 2010 
PDF Page 227
graphic on the right

The picture on the right on page 227 erroneously shows a navigation bar, which is not displayed by the app at this stage of progression (as proven by the illustration on page 229)

This causes readers to think they have missed something on the previous pages, I know I did and spent a while looking for it before reading ahead and discovering it was an error.

Solution: remove the navigation bar from the righthand illustration on page 229

note: A navbar is also displayed on page 224, but as that does not purport to represent the current code as entered, I think it is not a problem.

Cheers

Peter

Peter Johnson  Sep 06, 2010 
Printed Page 231
Add this section

There is no arrow for "Allocate the UINavigationController and pass in our AddDrinkViewController as its root view controller. It will retain the controller, since it needs to display it". This text is on a wrong position too.

I think only new things should be written in bold and not all. That mean:
- UINavigationController *addNavCon = [[UINavigationController alloc] initWithRootViewController:addDrinkVC];
- [self presentModalViewController:addNavCon animated:YES];
- [addNavCon release];

Furthermore there is a repetition of the description text compared to page 226:
- Now we just need to show ...
- Allocate the AddDrinkViewController just like ...

Especially the "Now we just need to show" paragraph isn't a good choice. Here something should said that the addNavCon is now used than the addDrinkVC before.

Anonymous  Aug 03, 2010 
Printed Page 233

In the end of chapter 5, we are told we can add save and cancel buttons. If one follows the directions exactly as described, one will find that some critical code is missing from the program which keeps the save and cancel buttons from showing up.
The DrinkMixerAppDelegate.m file needs the following code added immediately after "@synthesize navigationController;"

#pragma mark -
#pragma mark Application lifecycle

- (void)applicationDidFinishLaunching:(UIApplication *)application {

// Override point for customization after app launch

[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}

This code should appare before :

#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch.

// Add the navigation controller's view to the window and display.
[window addSubview:navigationController.view];
[window makeKeyAndVisible];

return YES;
}

It seems that file was forgotten altogether.

adam.d.benson  Oct 06, 2010 
Printed Page 236,238
Down section of the crossword puzzle

"2. The HIG requires some kind of DISCLOSURE element in a cell if there is more information availible."

availible -> available

Anonymous  Aug 03, 2010 
PDF Page 251
centre right notes

the phrase in the notes "we want the notification center to call us (the DetailViewController)" is misleading, it should be "...to call us (the AddDrinkViewController)", which is the file where the code will go.

The AddDrinkViewController is a subclass of DetailViewController, but they are not the same and this is an error. It states on page 256 that the code should be added to AddDrinkViewController

Peter

Peter Johnson  Sep 07, 2010 
Printed Page 256
Exercise Solution AddDrinkViewController.m file

-(void) viewWillDisappear:(BOOL) animated should call [super viewWillDisappear];

Neil  Aug 22, 2010 
258
Second Code Magnet

This code produces warning:
NSValue* aValue = [info objectForKey: UIKeyboardBoundsUserInfoKey] ;
CGSize keyboardSize = [aValue CGRectValue] . size;

UIKeyboardBoundsUserInfoKey is deprecated since 3.2.

Please give example of the new UIKeyboardFrameBeginUserInfoKey and UIKeyboardFrameEndUserInfoKey instead or

A way to test for wich sdk where on and then use the appropiate key/method to make view scroll.

Is is the same for
page 260 - code magnet 5
and of course the following pages where the code is shown and explained


Anonymous  Feb 21, 2011 
PDF Page 285
last paragraph

Relaunching the app does not display an added drink. Confirmed this by downloading your Chapter6/DrinkMixer (timestamp: 10/27/2009 9:49AM)

Don't see how it can work because relaunching app does not hit breakpoint in viewDidLoad.

I did the following:
1. added a new drink
2. observed that it showed up in the list
3. Did Hardware/Home in the iPhone Simulator
4. Retapped the Drink Mixer icon.

Ralph Bunker  Aug 06, 2010 
PDF Page 285
middle annotation and "watch it" section

This needs updating for iphone4, as following the instructions given will not test load and saving.

iPhone 4's multitasking implementation means it does not normally close down the application when the physical "button" is pushed, so when you select the icon again it just picks back up where it left off, it doesn't reload the data.

(this can be proven because it appeared to work even before the load and save code was added because the app wasn't terminated,)

Peter

Peter Johnson  Sep 07, 2010 
Printed Page 314
Step 1

After reading the "Watch it!" note, I upgraded from XCode 3.1 to 3.2. Then began Chapter 7. When I created the two new classes (FugitiveListViewController and CapturedListViewController) I found that two return values were expected (and undefined) in both of the .m files. As displayed below, I hard-coded return values of 1 (in both .m files) in order to get the app to run (p. 326)--

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1; //hardcoded for now!!
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 1; //hardcoded for now!!
}

Examining your completed code I see return values of 1 and 0 and 1 and [items count]. When were those return values assigned, and with what logic?

Richard Gardella  May 26, 2010 
Printed Page 324
iBountyHunterAppDelegate.m snippet

The book suggests adding the tabcontroller.view in the applicationDidFinishLaunching: method. The Apple docs recommend using application:didFinishLaunchingWithOptions: for SDK version 3.0 and later.

Rev_PJ  Jul 24, 2010 
Printed Page 327
Left hand image

After the detail view has been added, disclosure indicators should be used if the application is to conform to Apple's HIG.

Tony  Mar 02, 2011 
Printed Page 349
prior to instruction 3

Property declarations in iBountyHunterAppDelegate.h for managedObjectModel, managedObjectContext and persistentStoreCoordinator are missing from text.

@property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;

Darrel Plant  Apr 23, 2010 
Printed Page 359

iBountyHunter builds successfully, but Fugitives data doesn't display. I'm assuming the data is in "iBountyHunter.sqlite." I found such a file in your Ch. 7 download. So I added this into my project, but don't know where it belongs. How about an instruction somewhere on whether we need that file and where it needs to be added?

Paul Santori  Jan 15, 2011 
PDF Page 359
1st paragraph

I'm quoting Paul Santori,
I've followed all the tutorial from the beginning and at this point I copied your sqlite file from chapter 7 download zip file. I've uninstalled the app both from iPhone Simulator and the Application Support folder, but I still can't see anything in my tableView, it's completely empty.
I've written the 'createEditableCopyOfDatabaseIfNeeded' after the 'applicationDidFinishLaunching' and I get this warning: iBountyHunterAppDelegate may not respond to -createEditableCopyOfDatabaseIfNeeded. However if I write that method before the application launching I don't get any warning!

Can you explain me this? Where I should write that method, did I miss any line code?

Nicholas  Feb 06, 2011 
Printed, PDF Page 359
1st paragraph

For Paul Santori and Nicholas,
in my code I have
- (NSURL *)applicationDocumentsDirectory {
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}

since applicationDocumentsDirectory returns a (NSURL *), to get an (NSString *) you should do something like this

NSString *documentsDirectory = [[self applicationDocumentsDirectory] path];

this works for me on the simulator. Don't know if it's the more appropriate way...

lammic  Oct 16, 2011 
Printed Page 399
MIssing Instructions ?

I was expecting that the two new IBOutlets (capturedToggle and capturedDateLabel) would have been connected in Interface Builder. No mention of this step. ONce I did this then it all worked!

Printing history: October 2009 First Edition

Cheers!

BIll Allen  Feb 04, 2010 
Printed Page 402
Bottom right paragraph

The instruction to connect the 'capturedDateLabel' outlet to the File's Owner is omitted. Toggling the 'capturedToggle' segmented control will NOT show the date in the 'capturedDateLabel' unless that connection is made in Interface Builder.

Ronald Connal  May 20, 2010 
Printed Page 470
last statement in method

self.capturedDateLabel.text = @"" should be located within "else" brackets. The comment about this statement is also misleading.

Sandy B.  Sep 05, 2011 
Printed Page 476
top right code snippet

In the code for the CapturedPhotoViewController.h file, we are told to add "#import <MapKit/MapKit.h>". DIrectly below that, it reads "@class Fugitive;" If one makes the change from "#import "Fugitive.h" to "@class Fugitive;" as implied the app will crash. In short, do NOT make it read "@class Fugitive;"

adam.d.benson  Nov 18, 2010