mercredi 6 juillet 2016

swift if else fatal error unexpectedly found nil?

I have a problem getting this if else block to work as I wanted to. I have received the data from an API and while when I printed it it says "nil", however, the program still crashed

 print(i["dogs"]!!["breed"])
                if (i["dogs"]!!["breed"]) == nil {
                    item5.append(00000)
                } else {
                    item5.append((i["dogs"]!!["breed"] as! Int))
                }

the print prints out nil however, it seems that the if else block didn't work as I intended

thanks for the help !

Aucun commentaire:

Enregistrer un commentaire