Implementing Bronze Solution Killed my App


I’m at a serious loss, especially as a new programmer. When I implemented a couple of the solutions on the forum for the Bronze challenge, my app began to crash. I do appreciate the help and think that maybe I have something else wrong. I stepped through the program, it crashes when it attempts to load the DetailViewController. My DetailViewController.h and .m are attached. Please help!


// DetailViewController.m
// Homepwner
// Created by Seth Fuller on 1/19/14.
// Copyright © 2014 SoninLLC. All rights reserved.

#import “DetailViewController.h”
#import “SJDItem.h”

@implementation DetailViewController

@synthesize item;

-(void)setItem:(SJDItem *)i
item = i;
[[self navigationItem] setTitle:[item itemName]];

[super viewDidLoad];
[[self view] setBackgroundColor:[UIColor groupTableViewBackgroundColor]];

[super viewWillAppear];
[nameField setText:[item itemName]];
[serialNumberField setText:[item serialNumber]];
[valueField setText:[NSString stringWithFormat:@"%d", [item valueInDollars]]];

//Create a NSDateFormatter that will turn a date into a simple date string
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];

//Use filtered NSDate ofbject to set dateLabel contents
[dateLabel setText:[dateFormatter stringFromDate:[item dateCreated]]];

NSString *imageKey = [item imageKey];
    //Get image for image key from image store
    UIImage *imageToDisplay = [[BNRImageStore sharedStore] imageForKey];
    //Use that image to put on hte screen in imageView
    [imageView setImage:imageToDisplay];
    //Clear the imageView
    [imageView setImage:nil];


[super viewWillDisappear];

//Clear first responder
[[self view] endEditing:YES];

//Save changes to item
[item setItemName:[nameField text]];
[item setSerialNumber:[serialNumberField text]];
[item setValueInDollars:[[valueField text] intValue]];


  • (IBAction)takePicture:(id)sender {
    UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];

    //If our device has a camera, we want to take a picture, otherwise, we
    //just pick from photo library
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
    [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
    [imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];

    [imagePicker setDelegate:self];
    //[imagePicker setAllowsEditing:YES];

    //Place image picker on the screen
    [self presentViewController:imagePicker animated:YES completion:nil];


  • (IBAction)backgroundTapped:(id)sender {
    [[self view] endEditing:YES];

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
NSString *oldKey = [item imageKey];

//Did the item already have an image?
    //Delete the old image
    [[BNRImageStore sharedStore] deleteImageForKey:oldKey];

//Get picked image from ifo dictionary
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

CFUUIDRef newUniqueID = CFUUIDCreate(kCFAllocatorDefault);

//Create a string from unique identifier
CFStringRef newUniqueIDString = CFUUIDCreateString (kCFAllocatorDefault, newUniqueID);

//Use that unique ID to set our item's imageKey
NSString *key = (__bridge NSString *)newUniqueIDString;
[item setImageKey:key];

//Store image in the BNRImageStroe with this key
[[BNRImageStore sharedStore] setImage:image
                               forKey:[item imageKey]];

//Put that image onto the screen in our image view
[imageView setImage:image];

//Take image picker off the screen
//you must call this dismiss method
[self dismissViewControllerAnimated:YES completion:nil];


-(BOOL)textFieldShouldReturn:(UITextField *)textField
[textField resignFirstResponder];
return YES;


// DetailViewController.h
// Homepwner
// Created by Seth Fuller on 1/19/14.
// Copyright © 2014 SoninLLC. All rights reserved.

#import <UIKit/UIKit.h>
@class SJDItem;
#import “BNRImageStore.h”

@interface DetailViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate, UITextFieldDelegate>
__weak IBOutlet UITextField *nameField;
__weak IBOutlet UITextField *serialNumberField;
__weak IBOutlet UITextField *valueField;
__weak IBOutlet UILabel *dateLabel;
__weak IBOutlet UIImageView *imageView;

@property (nonatomic, strong) SJDItem *item;

  • (IBAction)takePicture:(id)sender;
  • (IBAction)backgroundTapped:(id)sender;



Walked through the program using breakpoints. The program steps fine all the way through the item setter method in the DetailViewController. Then it crashes.

I backed out the portion from the book that creates a UIControl our to the DetialView.xib file. Which resulted in no change.

Any help or advice would be greatly appreciated!



What message(s) are you getting in the debug console when the app crashes?

For future reference: It is best to put any code snippets in between the tags.




Thanks for replying. I’ve gotten the app to run and the detailView now pops up on the screen. Previously, I had tried to implement a connection when someone tapped on the picture. I had not removed that connection when I tried to implement the ideas here on the forum. Once I removed that connection from the XIB file, the app started loading the detailView screen again.

But, wait! There’s more!

Now I have a new issue. The detailView screen pops up but when I touch one of the text areas, it does not respond or bring up the keyboard, etc.

Any ideas?

I don’t get any more exception errors.


I’ve got it working! I had unchecked the ‘User Interaction Enabled’ when troubleshooting. I’m a victim of my own demise!


Just as a follow up, I was able to get the Bronze solution working. It was my own ignorance causing the trouble. But, what a good lesson to learn.

Consider this thread complete and solved!