I have a quick question.
According to apple official documentation
NSDateFormatter.dateFromString(String) would return
A date representation of string interpreted using the receiver’s current settings. If dateFromString: can not parse the string, returns nil.
let date = ""
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyyMMdd"
"Optional(1999-12-31 15:00:00 +0000)\n"
If dateFromString: can not parse the string, returns nil
The simple answer is, the
dateFromString does manage to parse an empty
string. If you try and put wrong data in the
"0" then you will get
Why is it happening? I assume that it is just they way the class is written, since the date formatter does skip missing data and try to complete it. There is probably not a case for "all is missing".