Why is `DateFormatter` Sendable but `ISO8601DateFormatter` isn't

I installed the latest Xcode version 16 beta 5 to try to enable swift 6 on my project and one of the errors I got led me to discover that the ISO8601DateFormatter is explicitly written as non-Sendable when DateFormatter is.

open class DateFormatter : Formatter, @unchecked Sendable { ... }

vs

@available(*, unavailable)
extension ISO8601DateFormatter : @unchecked Sendable {
}

Why is this so ?

Because NSDateFormatter was rewritten to do internal locking during the 2010s, but NSISO8601DateFormatter wasn't. See the list here Thread Safety Summary

2 Likes

As an alternative, you can use Date.ISO8601FormatStyle, which is Sendable.

NSISO8601DateFormatter isn’t on either list on that page, so I’m not sure that’s a sufficient explanation.

Huh, yeah, that documentation could probably use an update