LoginSignup
0
0

More than 1 year has passed since last update.

【Swift】Date型をデコード

Posted at

はじめに

いままでCodableでデコードする時にデータがあるとデコードに失敗してたのでStringでデコードしてました。

Dateでデコードする方法を学んだので記録しておきます。

方法

let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .iso8601
let weatherModel = try decoder.decode(WeatherModel.self, from: weatherData)

おわり

勉強になりました

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0