Errata

iOS 8 Swift Programming Cookbook

Errata for iOS 8 Swift 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
ePub Page 00
2.1 Adding New Photo Editing Capabilities to the Photos App

I think there is one missing point in this tutorial. You provide @IBOutlet for imageView but you never tell readers to really connect this outlet to the extension's view controller's UIImageView.

Mateusz ZajÄ…c  Jan 27, 2015 
4.1
Figure 4.7 and paragraph just above it

When creating a parental lock for the pool cover (characteristic), I could not find a "Locked" type (in HomeKit Accessory Simulator 1.0.1) . Maybe "Target Lock State" would work.

Paul D  Mar 23, 2015 
7.2
102 line of code

/Users/stephenzhou/Downloads/iOS-8-Swift-Programming-Cookbook-master/chapter-concurrency/Performing Non-UI Related Tasks/Performing Non-UI Related Tasks/ViewController.swift:102:14: 'NSData?' does not have a member named 'length'

let imageData = NSURLConnection.sendSynchronousRequest(urlRequest,
returningResponse: nil, error: &downloadError)

if imageData.length > 0{

Anonymous  Mar 06, 2015 
PDF Page 12
last paragraph

"Popovers are used to display temporary information on the screen. They can be used both on regular and on compact size devices such as iPads and iPhones."

Popovers can only be used on iPads. When running on iPhone, you will get the following exception:
NSInvalidArgumentException - UIPopovercontroller initWithContentViewController called when not running under UIuserInterfaceIdiomPad

Works fine under iPad - tested on iPhone 6

http://stackoverflow.com/questions/7687917/error-exception-nsinvalidargumentexceptionpad

http://stackoverflow.com/questions/26865306/nsinvalidargumentexception-reason-uipopovercontroller-initwithcontentview

Peter Girard  Dec 02, 2014 
ePub Page 13.1
Towards end of section 13.1, also in sample code on GitHub

When converting the unmanaged object (emails) to a managed object (allEmails), it should be tested first. Thus after:

let emails: ABMultiValueRef = ABRecordCopyValue(person,
kABPersonEmailProperty).takeRetainedValue() as ABMultiValueRef

test with:

if ABMultiValueGetCount(emails) > 0 { ... }

before using the returned value.

Anthony Scott  Jan 11, 2015 
Printed Page 44
last sentence

It says in you book: "The delegate of an instance of UIPickerView has to conform to the UIPickerViewDelegate protocol and must implement all the @required methods of that protocol."

But when you look at the class reference (e.g. by holding cmd and pressing on "UIPickerViewDelegate" in Xcode) there is no required function with the tag "@required".

Not an important issue but a mistake anyway.

Anonymous  Jan 04, 2015 
PDF Page 328
Chapter 7 - towards the top section

Hi,
App is crashing on iphone5 at

arrayOfRandomNumbers.append(randomNumber)

However I could not see the crash dump in the "Device Logs". I even tried the code available as part of your "Download Example Code" link. Also it is not giving info on the Xcode pane as well (little confused).

Do note that the app works in simulator of iPad Air.

My version of Xcode is
6.1.1 (6A2006)

Will keep debugging. I thought I will let you know.

Thanks

Anonymous  Nov 29, 2014 
PDF Page 581
Code at the bottom (func isFlashAvailableOnRearCamera())

func isFlashAvailableOnRearCamera() -> Bool{
return UIImagePickerController.isFlashAvailableForCameraDevice(.Front)
}

Should be (.Rear).

Same code has the same error.

Anonymous  Dec 14, 2015 
PDF Page 634
func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings!)

The badge counter code is written like the following, but the badge doesn't update:

/* Badge settings */
notification.applicationIconBadgeNumber++

This is the correct code:

// Badge settings
notification.applicationIconBadgeNumber =
UIApplication.sharedApplication().applicationIconBadgeNumber + 1

Anonymous  Dec 30, 2015 
PDF Page 663
didFinishLaunching

There should be a call to populateDatabase() in this method in order to illustrate the actual functionality of the app. As is, there are no results as the People database isn't populated (and thus there will never be a record that meets the criteria).

Anonymous  Jan 15, 2016 
PDF Page 698
Code

Running the code from the GIT provided by the author causes the app to crash after the code successfully executes:

"Application windows are expected to have a root view controller at the end of application launch occurred."

To fix this, you need to create a dummy root View Controller like this:

self.window?.rootViewController = UIViewController()

added after this line:

self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

Anonymous  Jan 29, 2016 
PDF Page 817
Lower third of page

This is wrong:

if isIcloudAvailable(){
displayAlertWithTitle("iCloud", message: "iCloud is not available." +
" Please sign into your iCloud account and restart this app")
return
}

It should be:

if !isIcloudAvailable(){
displayAlertWithTitle("iCloud", message: "iCloud is not available." +
" Please sign into your iCloud account and restart this app")
return
}

If you don't have the not in there, the code won't complete unless you're NOT logged into the iCloud.

Anonymous  Apr 20, 2016