I'm getting Crashlytics crash reports while using ISO8601DateFormatter with the formatOptions .withFractionalSeconds
to parse strings like this
2017-01-23T10:12:31Z
or
2017-01-23T10:12:31.484Z
or
2017-01-23T10:12:31.484221Z
to date with this code:
if #available(iOS 11.0, *) {
let formatter = ISO8601DateFormatter()
formatter.formatOptions.insert(.withFractionalSeconds)
result = formatter.date(from: string)
}
the crash message I'm getting is:
Fatal Exception: NSInternalInconsistencyException
Invalid parameter not satisfying: formatOptions == 0 || !(formatOptions & ~(NSISO8601DateFormatWithYear | NSISO8601DateFormatWithMonth | NSISO8601DateFormatWithWeekOfYear | NSISO8601DateFormatWithDay | NSISO8601DateFormatWithTime | NSISO8601DateFormatWithTimeZone | NSISO8601DateFormatWithSpaceBetweenDateAndTime | NSISO8601DateFormatWithDashSeparatorInDate | NSISO8601DateFormatWithColonSeparatorInTime | NSISO8601DateFormatWithColonSeparatorInTimeZone | NSISO8601DateFormatWithFullDate | NSISO8601DateFormatWithFullTime | NSISO8601DateFormatWithInternetDateTime))