I have the following code
let dateFormatter = ISO8601DateFormatter()
dateFormatter.formatOptions.insert(.withFractionalSeconds)
decoder.dateDecodingStrategy = .custom({ decoder in
let container = try decoder.singleValueContainer()
let dateStr = try container.decode(String.self)
return dateFormatter.date(from: dateStr) ?? Date() //warning
})
How do I fix the warning?
Capture of 'dateFormatter' with non-sendable type 'ISO8601DateFormatter' in a
@Sendableclosure