Gold Challenge


I found myself confused by trying to follow the pattern used for the Detail View Controller. I realized later that there is no need to copy the passed item, and so no need to utilize viewWillAppear, or viewWillDissapear.

I created a new controller, ChangeDateController and set up a Xib with a date picker and a “select” button. Essentially, the DetailViewController pushes the ChangeDateController onto the stack, passing the current item as a property of the new controller. When the “select” button is pressed, the passed item property “dateCreated” is changed to the datePicker’s property “date” and the ChangeDateController is popped. Done.

My Code:
in BNRDetailViewController:

- (IBAction)changeDate:(id)sender
    // create a date change controller instance and pass the current item to it
    NSLog(@"Date Change Entered");
    BNRChangeDateViewController *dateChangeController =
                [[BNRChangeDateViewController alloc] init];
    dateChangeController.item= self.item;
    // push the dateChangeConroller onto the stack
    [self.navigationController pushViewController:dateChangeController


#import <UIKit/UIKit.h>

@class BNRItem;

@interface BNRChangeDateViewController : UIViewController

@property (nonatomic, strong) BNRItem *item;



#import "BNRChangeDateViewController.h"
#import "BNRItem.h"

@interface BNRChangeDateViewController ()
@property (nonatomic, weak) IBOutlet UIDatePicker *datePicker;

@implementation BNRChangeDateViewController

- (void)viewWillAppear:(BOOL)animated
    [super viewWillAppear];
    // only reason overriding viewWillAppear is to put in a title
    self.navigationItem.title = @"Change Date";

- (IBAction)selectDate:(id)sender
    // place the date picker date in the item.dateCreated property
    // the item object will be changed in place
    self.item.dateCreated =;
    // pop the view off the stack
    [self.navigationController popViewControllerAnimated:YES];