Gold challenge - annoying lag when pressing button


Hi everyone!

I have completed the gold challenge by adding a ‘Change Date’ button to the DetailViewController’s XIB and by creating a DateViewController which I also connected to a XIB in order to load the UIDatePicker. Here goes my code (only included the relevant classes):


#import <UIKit/UIKit.h>
#import "BNRItem.h"

@interface DateViewController : UIViewController {
  __weak IBOutlet UIDatePicker *datePicker;

@property (strong, nonatomic) BNRItem *item;



#import "DateViewController.h"

@implementation DateViewController

@synthesize item;

- (void) viewWillAppear:(BOOL)animated {
  [super viewWillAppear: animated]; = item.dateCreated;

- (void) viewWillDisappear:(BOOL)animated {
  [super viewWillDisappear: animated];
  [item setDateCreated: [datePicker date]];



- (IBAction) changeDate:(id)sender {
  NSLog(@"Button Pressed!");
  DateViewController *dvc = [[DateViewController alloc] init];
  dvc.item = item;
  [[self navigationController] pushViewController: dvc animated: YES];

My issue is this: When pressing the ‘Change Date’ button in the detail view interface, the screen freezes for about 1-2 seconds and during this time the button appears to be pressed, but the view is only loaded after these 2 seconds have passed (I tried this on both my iPhone 4S and iPad 3 running iOS 7.1 beta 2). However, when running the app from within the simulator the transition is just fine … I cannot understand what is the reason of the slowdown when running the app on a device. The converse transition however (i.e. when going ‘Back’ from the date picker view to the detail view) behaves correctly.

There is one more thing I noticed in the activity monitor from within XCode: when pressing the ‘Change Date’ button, the CPU on the actual device is throttling at full speed for that short interval of 2 seconds and then kind of idles … Any ideas on what is going on here ?

Any help is very much appreciated. Thank you!