I have mysterious crash when trying to launch my app on iPhone (it perfectly valid works on Simulator though). I think problem is in this 2 methods..:
-(void)viewWillAppear:(BOOL)animated{
[self getValueFromPicker];
}
-(void)getValueFromPicker{
NSDate *now = [NSDate date];
NSDate *birthDate = self.birthdayPicker.date;
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit
fromDate:now
toDate:birthDate
options:0];
NSLog(@"Difference in years %i/", components.year);
}
App crash with SIGABRT error, and there is a text i can see in a console: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: date'
Please help me, i'am really have no idea what i did wrong, when i did the same thing on Simulator in console i can see difference in years from Now date and date, user picked.
Update:after i removed [self defaultBirthdayPickerDate]; in viewDidLoad section it start to work. But, now picker show current date, its not very convenient for picking birthday Date, now i still need to change its current date from now to past..
Mostly this types of error generated when you applies nil
date: check values of self.birthdayPicker.date
it is nil
or/not ?? and give proper condition if
you get nil
value of UIDatePicker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With