Reputation: 414
I'm trying to make a struct with optionals Codable/Decodable but I receive the error message:
Type 'item' does not conform to protocol 'Encodable'
Here is the code:
struct Item: Codable {
let domanda: String
let rispostaSemplice: Int?
var rispostaComplessa: [(testoRisposta: String, valoreRisposta: Bool)]?
}
How can I make the tuple [(testoRisposta: String, valoreRisposta: Bool)]?
conform?
Upvotes: 1
Views: 351
Reputation: 100503
You need
struct Item: Codable {
let domanda: String
let rispostaSemplice: Int?
var rispostaComplessa: [InnerItem]?
}
struct InnerItem: Codable {
var testoRisposta: String
var valoreRisposta: Bool
}
Upvotes: 3