Post

Replies

Boosts

Views

Activity

Reply to DateEncodingStrategy.custom encoder is immutable type?
Answer my own question here, it was a silly mistake from me, the error was about the container not the encoder, correct code looks as follows let encoder = JSONEncoder() encoder.dateEncodingStrategy = .custom({ date, encoder in var container = encoder.singleValueContainer() try container.encode(date.timeIntervalSince1970) }) It's been a long year!!!!
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’21