In my project, I need to show the date picker 18, and I need to block 80 years ago, since I can show this date in datepicker, can someone help me find here here I am adding the code, my code that I printed in the journal but i need to display on my datepicker since i can display
NSCalendar * gregorian = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar]; NSDate * currentDate = [NSDate date]; NSDateComponents * comps = [[NSDateComponents alloc] init]; [comps setYear: -18]; NSDate * minDate = [gregorian dateByAddingComponents: comps toDate: currentDate options: 0]; [comps setYear: -100]; NSDate * maxDate = [gregorian dateByAddingComponents: comps toDate: currentDate options: 0]; [comps release]; self.datePickerView.minimumDate = minDate; self.datePickerView.maximumDate = maxDate; NSLog(@"minDate %@", minDate); NSLog(@"maxDate%@", maxDate);
source share