I have the following piece of code which gives me the error
"Use of unresolved identifier 'randomcell'
But randomcell is clearly defined earlier on in the same function, why can the Else part not see it? I have tried redefining it inside the else part but it simply chooses another cell, I want to refer to the same random element in the second part of the function.
if seconds == 5 {
let randomcell = viewArray.randomElement()
randomcell?.backgroundColor = UIColor .red
}
else {
randomcell?.backgroundColor = UIColor .systemYellow
}
Aucun commentaire:
Enregistrer un commentaire