0

I'm working with a model -

struct Planet : Codable {
    var name : String
    var distance : Int
    var isSelected : Bool?
}

The data is being fetched from the server and only name and distance are provided by the server. I have added isSelected to keep track of the item being selected.

I'm using JSDecoder class to parse this data.

I tried using var isSelected : Bool ?? false but it gives compiler error.

Since the isSelected value is not provided by server, is there any way I can set the default value false to this?

Papershine
  • 4,995
  • 2
  • 24
  • 48
Love Kumar
  • 48
  • 6

0 Answers0