Errata

iOS 6 Programming Cookbook

Errata for iOS 6 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
PDF, ePub Page 1
1

Not a single word on UICollectionView and related classes (UICollectionReusableView, UICollectionViewCell, UICollectionViewController, UICollectionViewFlowLayout, UICollectionViewLayout, UICollectionViewLayoutAttributes and UICollectionViewUpdateItem) ???

Mazzaroth  Dec 20, 2012 
1.18
2nd code example in Discussion section

In the second code example of section 1.18 "Typecasting with Automatic Reference Counting", the comment "/*Compile time error!!! */" is carried over from the first code example, though the following text indicates that the compile time error was removed by the code change ("Perfect! Exactly what we wanted.").

dravetti  Jul 05, 2013 
PDF, ePub Page 124
last code sample on page

You use number of seconds assuming the calendar and performed an offset using that assumption. Why wouldn't you use the recommended method of date components for computing the offset.

Dates are always difficult as Apple recently learned with the iOS Do Not Disturb debacle, the last thing iOS needs is more people making bad date calculations.

I just checked your section of Date Handling and again on page 708 you repeat this error-prone approach.

What boggles my mind is that in place of the lengthy comment, you could have added...


- (NSDate*)dateForOneYearOffsetFromDate:(NSDate*)baseDate offsetInFuture:(BOOL)futureFlag
{
static NSCalendar *gregorian = nil;
if (gregorian == nil) {
gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
}
NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
[offsetComponents setYear:(futureFlag ? 1 : -1)];
return [gregorian dateByAddingComponents:offsetComponents toDate:baseDate options:0];
}

dlejr  Jan 09, 2013 
Printed, PDF, ePub, Mobi, , Other Digital Version Page 132

there is a mistake in the book ' iOS 6 Programming Cookbook' in page 132

/* 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 switched in those two lines of code the second belongs to the first and vice versa.
Best Regards,
Sarah Gheita

Adam Zaremba  Jan 22, 2013 
PDF Page 208
in the code

There are several references to "newImageViewWithImage", e.g.,

UIImageView *iPhoneImageView = [self newImageViewWithImage:iPhone frame:imageViewRect];

This method is not defined anywhere in the book, however it is in the sample code. Without this method, the solution code is meaningless as it will not compile and it is only marginally clear (thanks to the method's name) what that method returns.

Please either include the code itself or point the reader to the sample code on github:

- (UIImageView *) newImageViewWithImage:(UIImage *)paramImage
frame:(CGRect)paramFrame{

UIImageView *result = [[UIImageView alloc] initWithFrame:paramFrame];
result.contentMode = UIViewContentModeScaleAspectFit;
result.image = paramImage;
return result;

}

Bryan Hanks  May 09, 2013 
Printed Page 223
Recipe 2.27

iOS 6 has an issue with the use of the identifier "popoverController". It conflicts with the identifier "_popoverController" that already exists in the SDK. I changed all the instances to "myPopoverController".

George Thompson  Apr 15, 2013 
Printed Page 231
Code at the top of the page

The app will not run because of the identifier "barButtonAdd".

George Thompson  Apr 15, 2013 
Printed Page 316
Code

The code for moving a cell from section 1 to section 2 does not function property. I get this error:

The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (3), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 1 moved out).'

I haven't tried it, but it would appear that I would also have to move a cell from section 2 back to section 1 to compensate for the move.

George Thompson  Apr 15, 2013 
Printed Page 382
Line 16

The code:

NSData *imageData = [NSURLConnection etc
apparently does not fit the current format for this object. Code completion asks for "queue:" and "completionHandler:"

Code will not function as written.

George Thompson  Apr 21, 2013 
Printed Page 403
Near the bottom

"simpleOperation" is not declared property for this version of the app. I was able to get it to work by changing the code to:

CountingOperation *simpleOperation = [[CountingOperation alloc] initWithStartingCount:0 endingCount:1000];

[simpleOperation start];

George Thompson  Apr 26, 2013 
PDF Page 608
close to bottom

you say: [picker dismissModalViewControllerAnimated:YES];

it should be:[[picker presentingViewController] dismissViewControllerAnimated:YES completion:nil];

your code is deprecated in iOS 6.0

Anonymous  Dec 28, 2012 
ePub Page 2218
Solution

The exercise as written and also as found in the sample code "Retrieving the List of Calendars.xcodeproj" does not work with iOS6.0.1 it does however work with iOS 5.1.1
The code does not produce any output. The "For loop construct" "for (EKCalendar *thisCalendar in eventStore.calendars)" is not entered.
I would be really pleased if you told me how to change the code to make it work with iOS 6

Kind regards

Adrian Willis

Adrian Willis  Dec 17, 2012 
ePub Page 2219
Exercise 16.1

I have found the solution to my bug that I explained previously. iOS 6 requires the user to grant your App access to the Event Stores.
If you put this code in, it will work nicely:

/* iOS 6 requires the user grant your application access to the Event Stores */
if ([eventStore respondsToSelector:@selector(requestAccessToEntityType:completion:)])
{
/* iOS Settings > Privacy > Calendars > MY APP > ENABLE | DISABLE */
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error)
{
if ( granted )
{
NSLog(@"User has granted permission!");
}
else
{
NSLog(@"User has not granted permission!");
}
}];
}

Adrian Willis  Dec 17, 2012