Errata

iOS 7 Programming Cookbook

Errata for iOS 7 Programming Cookbook

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 Page xviii
1st paragraph

The section Using Code Examples says that the example code is at https://github.com/oreillymedia/iOS_7_programming_cookbook

but it's actually at
https://github.com/oreillymedia/iOS_7_Programming_Cookbook

(note the capital 'P' and 'C') - I'm sure it's easier to move the repository to the right place (lowercase 'p' and 'c'), but couldn't figure out who to contact for the github repository.

Anonymous  Oct 29, 2013 
PDF Page XVIII Preface
1st paragraph at the top of the page

The referenced source code cannot be downloaded due to the following two errors:

1. referred to from my ORA download page:

https://github.com/oreillymedia/iOS_7_Programming_Cookbook

Nothing there but a REAME.md FILE.

2. https://github.com/oreillymedia/iOS7_programming_cookbook

ERROR 404 (page not found)

Please fix this ASAP so I can download the promised source code.

Martin Turner  Oct 30, 2013 
PDF Page Page XVIII Preface
1st paragraph at the top of the page

he referenced source code cannot be downloaded due to the following two errors:

1. referred to from my ORA download page:

https://github.com/oreillymedia/iOS_7_Programming_Cookbook

Nothing there but a REAME.md FILE.

2. https://github.com/oreillymedia/iOS7_programming_cookbook

ERROR 404 (page not found)

Please fix this ASAP so I can download the promised source code.

2 Nov 2013

I have just been informed by ORA that the source code can actually be found a (and I was able to access it)t:

https://github.com/vandadnp/ios-7-programming-cookbook-source-codes

Martin Turner  Nov 01, 2013 
PDF Page Page No 177
collissionBehavior method of the delegate implementation

CGAffineTransformMakeScale(2.0f,2.0f) is expected to double the size of the view before it gets removed. However this is not happening when the program gets executed on the device.

Partha  Dec 31, 2013 
, Other Digital Version

Chapter 2
Sample from github "Attaching Multiple Dynamic Items to Each Other"

ViewController "ViewControler"
In Selector "createAnimatorAndBehaviors"
..
self.attachmentBehavior = [[UIAttachmentBehavior alloc]
initWithItem:self.squareView
point:self.squareViewAnchorView.center
attachedToAnchor:self.anchorView.center];
..
should be?
..
self.attachmentBehavior = [[UIAttachmentBehavior alloc]
initWithItem:self.squareView
attachedToItem: self.anchorView];
..

Pareshkumar N. Suthar  May 24, 2014 
Printed Page page xvii
Under Conventions Used In This Book

I looked thoroughly but I don't see "Constant width bold" which is supposed to show commands or other text that should be typed literally by the user. What's going on here? Furthermore, has any of the unconfirmed errata been checked for it's accuracy? I find it very disturbing that a book for this price hasn't been carefully vetted.

Anonymous  Jul 30, 2014 
PDF, ePub Page 1
Mexico

Ch01, page 01

Considering the provided example:
"NSInteger myNumber = -20;"

3rd paragraph says: "... NSInteger and sets its value to 10..."
It should be "... NSInteger and sets its value to -20..."

also 3rd paragraph: "...In this case, when we set 10 as the value of..."
It should be: "...In this case, when we set -20 as the value of..."

Angel Jonathan GM  Sep 23, 2013 
PDF Page 1
3rd paragraph

the code listed:
NSInteger myNumber = -20;

however, text in 3rd paragraph talks about 10

Anonymous  Sep 27, 2013 
PDF Page 1
3rd paragraph

The initial example in paragraph 2 uses -20 (Minus Twenty) for the NSInteger myNumber, but then in paragraph 3, the number used it 20 (Positive Twenty).

Anonymous  Feb 15, 2014 
Other Digital Version 2
recipe 2.4

In the example code chapter 2, recipe 2.4 the code describes a method initWithItem:point:attachedToAnchor, but this instance method does not exist.

Anonymous  Feb 03, 2015 
PDF, ePub Page 3
Mexico

Ch01, page 03

bullet 04 says: "...and ensure that the Use Storyboards and the Include Unit Tests checks are not enabled, and that the Use Automatic Reference Counting check is enabled..."

Those options are not available in xcode 5. When selecting the device family, there are no other option available and every application is created with Storyboard unless "Empty Application" is selected as the project template.

The worst thing is that page 02, 5th paragraph says that: "To reproduce the examples, follow the instructions in 'Creating and Running Our First iOS App' on page 2." Therefore it will be complicated to get the examples running as expected since Storyboarding changes the whole design & programming of an application. This same issue comes from the previous iOS 6 cookbook edition.

Angel Jonathan GM  Sep 23, 2013 
Printed Page 4
1st paragraph

Under the section Mutable Versus Immutable there is a typo in the first sentence. "if" should be "it".

Actual Text:
"If a data type is mutable, you can change if after it is initialized."

Expected Text:
"If a data type is mutable, you can change it after it is initialized."


Randall Lutcavich  Oct 14, 2014 
Printed Page 5
3rd Paragraph From the Bottom

An extra word ("of") is included in the first sentence of the third paragraph from the bottom.

Actual: "Getting data from the original float is a simple dereference (myFloat), whereas getting the value of through the pointer requires the use of the asterisk (*pointerFloat).

Expected: "Getting data from the original float is a simple dereference (myFloat), whereas getting the value through the pointer requires the use of the asterisk (*pointerFloat)."

Randall Lutcavich  Oct 14, 2014 
Printed Page 19
middle of page

__unused NSString *secondObject = array[0];
should be
__unused NSString *secondObject = array[1];

Anonymous  Oct 25, 2013 
PDF, ePub Page 21
Mexico

Ch01, page 21

1st paragraph says: "...it?s an object that we can make a copy of if we...".
It should be "...it?s an object that we can make a copy of it if we..."

Angel Jonathan GM  Sep 23, 2013 
PDF Page 25
3rd and 4th paragraph

The descriptions of "title" and "message" contain errors.

The description of "title" says:

title
The string that the alert view will display on top when it is shown to the user. This string is Title in Figure 1-2.

The string is not "Title". It is "Alert".

message
The actual message that gets displayed to the user. In Figure 1-2, this message is set to Message.

The string is not "Message". It is "You've been delivered an alert".

Anonymous  Feb 16, 2014 
PDF Page 30
Figure 1-4

The dialog shows a number with dashes, but the keyboard does not allow the entry of dashes. So the text in the field could not have been typed on this keyboard, unless some auto-formatting was in place, which is not described in this example.

Anonymous  Feb 16, 2014 
PDF, ePub Page 41
Ch01, page 41, code snippet

Since in recipe 1.3 variable mainSwitch refers to previous switch declared in recipe 1.2, the correct name for this switch variable should be "self.mySwitch" instead of "self.mainSwitch".

Angel Jonathan GM  Sep 28, 2013 
PDF, Mobi Page 56
56

Ch01, Ex07

In the next piece of code:

/* Set the tint color of the thumb */
self.slider.maximumTrackTintColor = [UIColor greenColor];

/* Set the tint color of the maximum value */
self.slider.thumbTintColor = [UIColor blackColor];

the comments are wrong. The first one is the maximum value and the second one is the thumb.

Lalo  Nov 04, 2013 
PDF, ePub Page 62
Ch01, Recipe 1.7, Page 62, Code snippet

Since the variable "self.slider" from recipe 1.7 makes reference to the variable declared in previous recipe 1.6, then the variable "self.slider" should be "self.mySlider" instead.

Angel Jonathan GM  Sep 28, 2013 
PDF, Mobi Page 63
Example code

The method "roundedValuesInRect" it's missing.
The program doesn't compile.

- (CGRect) roundedValuesInRect:(CGRect)paramRect{
paramRect.origin.x = round(CGRectGetMinX(paramRect));
paramRect.origin.y = round(CGRectGetMinY(paramRect));
paramRect.size.width = round(CGRectGetWidth(paramRect));
paramRect.size.height = round(CGRectGetHeight(paramRect));
return paramRect;
}

Lalo  Oct 06, 2013 
PDF, ePub Page 64
Ch01, Recipe 1.7, Page 64, 2nd Paragraph

At the end of the 2nd paragraph it says "Obviously, you need to provide a 46x46 image for retina displays".
Is this valid for minimum track image, which should be 11 points wide and 9 points tall??

Angel Jonathan GM  Sep 28, 2013 
PDF Page 64
United States

In the book, it says "Now that you have created an application using the Empty Application template in Xcode, follow these steps to create a new view controller for your app:"

At this point in the book, we have never been asked to create an application with the Empty Application template. There is nothing telling the reader that they should create one or how to do it preceding this mention.

Anonymous  Feb 23, 2014 
PDF, ePub Page 71
Ch01, Recipe 1.8, Page 71, Code snippet

xCode 5.0 does not display the selected image for segmented control.

Angel Jonathan GM  Sep 28, 2013 
PDF Page 71
code snippet in middle of page

can't change size.height of UISegmentedControl in iOS 7. haven't been able to find this in Apple's documentation, but neither can you change it, nor can you change it in Storyboard.

CGRect segmentedFrame = self.mySegmentedControl.frame;
segmentedFrame.size.height = 128.0f;
segmentedFrame.size.width = 300.0f;
self.mySegmentedControl.frame = segmentedFrame;

ddelwood  Oct 05, 2013 
PDF, ePub Page 92
Ch01, Recipe 1.12, Page 92, image 1-33

The image provided does not match with code snippet from page 91 (we haven't set nav bar title neither created a label).

Angel Jonathan GM  Oct 02, 2013 
Printed, PDF Page 98
2nd paragraph

"It turns out that every view controller has a property called tabItem."

tabItem above should be tabBarItem

WillM  Jan 16, 2014 
Printed, PDF Page 121
method handleKeyboardDidShow:

The recipe calls for using contentInset to compensate for the keyboard. The code written as-is does not work for iOS7. Based on the research I did, Apple switched from using WebKit to TextKit for UITextView and a few bugs came along in the process. Using contentInset does not work; re-sizing the frame appears to work.

WillM  Jan 19, 2014 
Printed, PDF Page 121
method handleKeyboardDidShow:

Note: I posted that re-sizing the frame appears to work, however, it does not work in all cases I tried later. Looks like there are a number of issues with iOS7 and UITextView.

WillM  Jan 19, 2014 
Printed, PDF Page 144
2nd paragraph

Says "In iOS 7, we can start using attributed strings."

This implies Attributed Strings were not available until iOS 7. Attributed Strings were available before iOS 7.

WillM  Jan 22, 2014 
Printed, PDF Page 155
2nd paragraph (under Delegate Class)

Says "The app delegate simply creates an instance of the RootViewController class and presents it to the user."

I don't see anywhere in the app delegate code that creates an instance of the RootViewController class and presents it to the user.

Says "There is one .xib for iPad and another one for iPhone".

Xib files are not created, however, Storybook files are created, one for the iPad and another one for the iPhone.

WillM  Jan 28, 2014 
Printed, PDF Page 157
3rd paragraph

Says "The first method gets called when the page view controller already has a view controller on the screen and needs to know which previous view controller to render. This happens when the user decides to flip to the next page."

Shouldn't this say "when the user decides to flip to the previous page"? I placed an NSLog in both methods and saw the first method (pageViewController:viewControllerBeforeViewController:) get called when I did a previous page flip.

WillM  Jan 28, 2014 
Printed, PDF Page 161
Pages 161-162 (code starting with isInPopover

Method isInPopover does not appear to be necessary. PopoverContentViewController, where this method resides, is only used by iPad. Therefore, there appears to be no reason to even check if it's a popover. In addition, the other two methods (gotoAppleWebsite: and gotoAppleStoreWebsite:) are target/actions for iPad only, thus, the code never gets executed for iPhone. The comments in each of these methods that says "Handle case for iPhone" is misleading. To double check, I placed debug breakpoints in each of these methods. They were only called when running with iPad.

WillM  Jan 28, 2014 
Printed, PDF Page 179
3rd paragraph

says "One of the interesting properties of the UIGravityBehavior class is collisionMode."

collisionMode is a property of UICollisionBehavior.

WillM  Feb 02, 2014 
PDF, ePub Page 181
Ch01, recipe 28 , 2nd paragraph

It says "There is one .xib for iPad and another one of iPhone..."
As for xcode 5, xib files are not provided/created anymore. Storyboards are the way to go.

Most of the recipes from ch01 are considering another xcode version different from iOS7 apps... and this book is supposed to be focused on iOS7 !!!

Angel Jonathan GM  Oct 16, 2013 
PDF, ePub Page 184
Ch01, recipe 28, 1st paragraph

It says "This happens when the user decides to flip to the next page...".
Since the viewcontroller needs to know which previous view controller to render, then it should say "This happens when the user decides to flip to the PREVIOUS page".

Something similar happens in the following method explanation. It says "The second method is called when the page view controller needs to figure out which view controller to display after the view controller that is being flipped."
It should be "The second method is called when the page view controller needs to figure out which view controller to display BEFORE the viewcontroller that is being flipped."

Angel Jonathan GM  Oct 16, 2013 
Printed, PDF Page 186
squareViewAnchorView

Along with Ilya's post (page 187, on Oct 23, 2013), the view squareViewAnchorView does not appear to be necessary for this code to work. All references can be removed from the code and it will still work the same.

WillM  Feb 06, 2014 
PDF Page 187
- (void) createAnimatorAndBehaviors{ ... self.attachmentBehavior = ...}

The method signature has changed, and the former call causes an error -

self.attachmentBehavior = [[UIAttachmentBehavior alloc]
initWithItem:self.squareView
point:self.squareViewAnchorView.center
attachedToAnchor:self.anchorView.center];

No we have to write so -

self.attachmentBehavior = [[UIAttachmentBehavior alloc]
initWithItem:self.squareView
attachedToAnchor:self.anchorView.center];

Ilya  Oct 23, 2013 
PDF, ePub Page 189
Ch01, Code snippet

In methods gotoAppleWebsite and gotoAppleStoreWebsite there's else statement for hanlding "case for iphone". Are those "else statement" really needed? After all, PopoverContentViewController will be created only when device is an iPad (see construction in viewDidLoad method on page 190). I think an else statement handling iphone case in this part of the code is unnecessary.

Angel Jonathan GM  Oct 18, 2013 
Printed, PDF Page 217
Pages 217-219

This solution appears to be pre-Xcode 5. With Xcode 5, when checking Use Autolayout, no constraints are created. The developer can create the constraints at any time by control-dragging from the view object, or using the Resolve Auto Layout Issues and/or Pin buttons.

Discussion (page 218) 2nd paragraph, creating a new Single View Application project in Xcode 5 does not create a .xib file. This would have to be done with File/New/File, selecting Objective-C class, then checking "With XIB for User Interface". For both an XIB file and a Storyboard File, dragging a button onto the center of the screen until the IB guidelines appear on the screen will not create constraints in Xcode 5.

WillM  Jan 16, 2014 
PDF Page 230
viewDidLoad

delegate is not set for table view so the disclosure button does nothing when clicked. Solution:
self.myTable.delegate = self and make the controller adopt the UITableViewDelegate protocol

Christos K  Apr 12, 2014 
PDF Page 275
1st block of code in that page

In that block of code you have a line with the following code:

self.refreshControl = self.refreshControl;

I don't know if it's a simple typo and you should remove that line (because that code isn't doing anything) or if it's a mistake and you wanted to write a different thing in that specific line (something functional and not a piece of dead code that can be ignored)

Andre Fonseca  Feb 02, 2014 
PDF Page 290
Last paragraph

In IOS 7 we get error when will change orientation of device screen:

- (NSInteger)numberOfSectionsInCollectionView :(UICollectionView *)collectionView{
return [self allSectionColors].count;
}

The correct version of this

- (NSInteger)numberOfSectionsInCollectionView :(UICollectionView *)collectionView{

[self.collectionView.collectionViewLayout invalidateLayout];
return [self allSectionColors].count;
}

Ilya  Oct 31, 2013 
PDF, ePub Page 354
recipe 2, 1st paragraph

It says: "Now place another view controller from the Object Library onto your storyboard and place a button and a text field on the first view controller as well."

Placing another view controller from the Object Library onto the storyboard will not automatically create the .h and .m files for that view. At this point, it is not possible to follow this recipe.

Angel Jonathan GM  Oct 19, 2013 
PDF, ePub Page 358
Ch06, recipe 2, code snippet

at prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender method, code line:

[nextController setText:self.textField.text];


gives the following error: "No visible @interface for SecondViewController declares the selector setText:self:"

This method should also be declared at header file.

Angel Jonathan GM  Oct 19, 2013 
Printed Page 441
middle of page in applicationDidFInishLaunching:withOptions:

I don't see how this query can work. You are including kSecAttrSynchronizable in the query used for finding the items to delete. Since you are deleting them in order to make them synchronizable, the query will not find them because they are not yet synchronizable (they don't yet have the kSecAttrSynchronizable key);

Alan McKean  Mar 03, 2014 
PDF, ePub Page 527
Ch10, recipe 2, code snippet

Does it make sense to ask for swipe gesture direction Down, Right, and Up? Those conditions will not be "executed" since we are limiting our swipe gesture left only in declaration of viewDidLoad method.

Angel Jonathan GM  Oct 19, 2013 
Printed Page 838
1st paragraph

I couldn't for the life of me get the font to show for the given color (magenta) as written. I am currently at the up-to-date version of xcode.

After some sleuthing, it seems that the color is passed in as an attribute to drawAtPoint as of ios7, ie,

[myString drawAtPoint:CGPointMake(25, 190)
withAttributes:@{
NSFontAttributeName : helveticaBold,
NSForegroundColorAttributeName : magentaColor
}];

This worked for me.

Anonymous  Nov 20, 2013 
Printed, PDF, ePub Page 904
if ([self.view drawViewHierarchyInRect:self.view.bounds]){

Reports error when code is pasted into @implementation of View controller:

@implementation CkrsViewController
- (void) viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];

/* Capture the screenshot */
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, 0.0f);
if ([self.view drawViewHierarchyInRect:self.view.bounds]){
NSLog(@"Successfully draw the screenshot.");
} else {
NSLog(@"Failed to draw the screenshot.");
}
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

/* Save it to disk */
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSURL *documentsFolder = [fileManager URLForDirectory:NSDocumentDirectory
inDomain:NSUserDomainMask
appropriateForURL:nil
create:YES
error:nil];
NSURL *screenshotUrl = [documentsFolder
URLByAppendingPathComponent:@"screenshot.png"];

NSData *screenshotData = UIImagePNGRepresentation(screenshot);

if ([screenshotData writeToURL:screenshotUrl atomically:YES]){
NSLog(@"Successfully saved screenshot to %@", screenshotUrl);
} else {
NSLog(@"Failed to save screenshot.");
}

}

This is the reported error text

No visible @interface for 'UIView' declares the selector 'drawViewHierarchyInRect:'

Is there something needed in a .h file or maybe must use a storyboard?

Placed a custom button with image on the storyboard and still error remains?

Gay Stout  Dec 27, 2013 
ePub Page 1075
Ch14, recipe 6

In code snippet for nscoding protocol method "(instancetype)initWithCoder:(NSCoder *)aDecoder?, it is not clear the form in which the variables _firstName and _lastName are being called. Why the underscore?

Angel Jonathan GM  Nov 03, 2013 
ePub Page 1182
Ch14, introduction

In "Documents/" folder explanation, you state the following:
?This folder is the destination for all user-created content."
but also states that:
"Content that your app has populated, downloaded, or created should NOT be stored in this folder.?
So... is this folder for user-created content or not? I mean, if the user creates a folder or a file, should it be stored into "Documents" folder? If not... where? The statement is confusing.

Angel Jonathan GM  Nov 03, 2013