NSDateFormatter is returning nil when I try to parse the string @”02291120″ with the formatter string
@"MMddHHmm"
However, Feb 29 is a valid date (for a leap year). How do I make sure the result returned by the parser is not nil?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You didn’t tell the date formatter what year to use.
If you don’t include the year in your date format, then it uses 1970 by default. If you want it to use a different year by default, you have to give the date formatter a default date. For example, if you want it to use the current year, you can just set the default date to the current date: