In a navigation controller I push out a view with a uidatepicker. There's also a label that I'm updating through a function 'changeDate' this is loaded up as follows
Everything is working as long as you're playing nice. If you would give the datepicker a good flick and then immediately tap the save button the app crashes.
The app crashes because the save function has completed everything and popped the view back before the datepicker has stopped spinning. The datepicker eventually stop spinning and tries to talk to 'changeDate' which is nowhere to be found and the app duly crashes.
How can I best go about this? Can I invalidate the datepicker. Would I have to have my save function wait for the datepicker to finish before popping back?
Code:
...
datePicker.date = [NSDate date];
[datePicker addTarget:self action:@selector(changeDate:) forControlEvents:UIControlEventValueChanged];
[pickerView addSubview:datePicker];
[datePicker release];
...
- (void) changeDate:(id)sender {
...
- (void) save {
[self unloadPickerView];
...
[self.navigationController popViewControllerAnimated:YES];
- (void) unloadPickerView {
// gets the uiview with the picker view and removes all views from subviews
Everything is working as long as you're playing nice. If you would give the datepicker a good flick and then immediately tap the save button the app crashes.
The app crashes because the save function has completed everything and popped the view back before the datepicker has stopped spinning. The datepicker eventually stop spinning and tries to talk to 'changeDate' which is nowhere to be found and the app duly crashes.
How can I best go about this? Can I invalidate the datepicker. Would I have to have my save function wait for the datepicker to finish before popping back?