I have a problem. I have 3 text field for day, month, year to get date input from the user I do not want to use a date picker. Instead I create a string from all three inputs in the format dd/mm/yy and use a date formatter like so to assess the validity.
NSDate *convertedDOB = [dobFormatter dateFromString:dateOfBirth];
if (convertedDOB == nil){
NSLog(@"DATE EPIC FAIL");
}
else{
NSLog(@"DATE OK");
}
[dobFormatter release];
If I enter something stupid like 10/40/88 it returns an error, however date of the type 40/12/88 or 30/02/88 go undetected. Is there anything I’m doing wrong? Thanks.
You should probably use NSDatePicker so that errors like this can be prevented.
http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSDatePicker_Class/Reference/Reference.html
Also, you may be getting
nilas the date format entered is different to the date format of the NSDateFormatter.