Frage

Remote API's date format is expected to change in the future from the current custom format to ISO 8601. Looking for the efficient way to validate string date format before converting it to the NSDate using proper NSDateFormatter.

War es hilfreich?

Lösung

The easiest way to validate the format is to actually try converting the string using your date formatter. If it returns nil then the format isn't a match and you can try the other format.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top