LoginSignup
4
2

More than 5 years have passed since last update.

error:Type '' does not conform to protocol 'Decodable' & 'Encodable'

Posted at

はじめに

jsonをパースする際にとても便利なCodableプロトコルでの分かりづらいエラーをメモ。

改善

こんな感じで起きる。
fullsizeoutput_9b.jpeg
明確な型定義がされていないと起こるらしいので、これをString型に定義する。

ViewController.swift
struct Item: Codable {
        let itemName: String
    }

これでエラーはなくなり無事成功。

4
2
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
4
2