In your dateChanged:
method you are accessing a variable named datePicker
. Is this an instance variable?
Assuming it is, you never set it. In your viewDidLoad
you have a local variable named datePicker
that you use but that is different from the instance variable with the same name.
In viewDidLoad
, change:
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
to:
datePicker = [[UIDatePicker alloc] init];
That will fix it.
You should also change your dateChanged:
method to:
- (void) dateChanged:(UIDatePicker *)picker {
// Add the date to the dueDate text field
NSLog(@"Date changed: %@", picker.date);
}