Major typo in the book for BNRItem properties


So my Kindle version of the book shows this:

[code]#import < Foundation/ Foundation.h >
@import CoreData;

@interface BNRItem : NSManagedObject

@property (nonatomic, strong) NSDate * dateCreated;
@property (nonatomic, strong) NSString * itemKey;
@property (nonatomic, strong) NSString * itemName;
@property (nonatomic) double orderingValue;
@property (nonatomic, strong) NSString * serialNumber;
@property (nonatomic, strong) UIImage *thumbnail;
@property (nonatomic, strong) NSData * thumbnailData;
@property (nonatomic) int valueInDollars;
@property (nonatomic, strong) NSManagedObject *assetType;

  • (void) setThumbnailFromImage:( UIImage *) image;


Which really freaked me out because my CoreData object showed it was using ‘retains’ to manage references. (iOS4 style)

Going to the Solutions bundle and looking at the version by John Gallagher (BNR Employee / Author):

//  BNRItem.h
//  HomePwner
//  Created by John Gallagher on 1/9/14.
//  Copyright (c) 2014 Big Nerd Ranch. All rights reserved.

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@interface BNRItem : NSManagedObject

@property (nonatomic, retain) NSString * itemName;
@property (nonatomic, retain) NSString * serialNumber;
@property (nonatomic) int valueInDollars;
@property (nonatomic, retain) NSDate * dateCreated;
@property (nonatomic, retain) NSString * itemKey;
@property (nonatomic, retain) UIImage * thumbnail;
@property (nonatomic) double orderingValue;
@property (nonatomic, retain) NSManagedObject *assetType;

- (void)setThumbnailFromImage:(UIImage *)image;


If your eBook is the same as mine go with what John has done above and ignore your ebook version. It’s obviously a typo.



After freaking out about the major code generation issues I did see this ‘disclaimer’ in the book.

[quote](Xcode might have created the strong properties as retain. These represent the same thing; before ARC, strong properties were called retain, and not all parts of the tools have been updated to the new terminology.)

Technical books should do what they say and say what they do. Showing me code that is NOT in the finished example program is very uncool.

The CoreData lesson samples in the 3rd Edition didn’t even include that disclaimer.

My guess is the authors were thinking Xcode 5.X would make the book code valid ? Still seems odd to me that the code in the samples doesn’t match the code shown in the book.

It’s crazy how much Apple changes things in a year. BNR should consider a simple ‘Intro’ class and then online training for sections.
There are really two sets of developer camps to consider. (Assuming someone at BNR reads this. =) )

A. Brand new to iOS development.
B. Developer not new but hasn’t had time to figure out Apple’s latest updates to iOS N or can’t afford a trip to WWDC or wasn’t online at 2AM to buy a ticket.

There is also a subset that both A and B folks should have in their training.

Good practices on team development. Using Git, Apple’s OSX Server builds, unit testing, code formatting and how to structure your projects.
I was kind of sad they didn’t mention how to create sub folders in your project to group things. Put all of your data classes in a folder called ‘model’ for example.
I also was a little annoyed by how many times I saw “-(void)SPACE” and “-(void)methodName” in the code. Code consistency on very large projects is important. You can’t ADD code quality at the end when you have to ship and you are trying to track down a bug. There is no time and anything worth doing is worth doing right in my humble opinion.

OK, enough of my rant. BNR is a good group of folks and there books are well written.



It makes no difference if you replace “retain” with “strong”. The programs behaves exactly the same.

What really confused me was the book contains an extra attribute in figure 23.8 “ThumbnailData - Binary” and also in the corresponding code, which it did not ask you to create. It’s not in the downloaded iOS solutions, so must have been accidentally carried over from previous versions of the book.