Chapter 11. Is here an error?
In BNRDetailViewController.m, add code to viewWillAppear:
to do this.

    - (void)viewWillAppear:(BOOL)animated

[super viewWillAppear];

self.nameField.text = item.itemName;

self.serialNumberField.text = item.serialNumber;
self.valueField.text = [NSString stringWithFormat:@"%d",

static NSDateFormatter *dateFormatter = nil;
if (!dateFormatter) {
    dateFormatter = [[NSDateFormatter alloc] init];
    dateFormatter.dateStyle = NSDateFormatterMediumStyle;
    dateFormatter.timeStyle = NSDateFormatterNoStyle;

self.dateLabel.text = [dateFormatter stringFromDate:item.dateCreated];

[color=#FF0000] NSString *imageKey = self.item.imageKey;[/color]

// Get the image for its image key from the image store
UIImage *imageToDisplay = [[BNRImageStore sharedStore] imageForKey];

// Use that image to put on the screen in the imageView
self.imageView.image = imageToDisplay;



Yes, that should be NSString *itemKey = self.item.itemKey;


Newbie here! Even with the fix just noted (imageKey -> itemKey), I still get an error on self.nameField.text = item.itemName; (and other lines) unless I add BNRItem *item = self.item;

The code then works to this stage (just before “dismissing the keyboard”), and I see pictures that I previously stored.

Did I miss a step earlier that would have avoided the need to add this line?



In -viewWillAppear:?

While it’s missing from the (unhighlighted) code at the top of page 228, it WAS included when the method was created in the previous chapter, on page 204.

So you’re right that it is an error in the code listing (on 228).