I am trying to copy an array and its values. Why are both arrays referencing the same variable? You can try this in Playground.
var view = UIView()
view.tag = 1
var a = [UIView]()
var b = [UIView]()
a.append(view)
b = a
view.tag = 2
a[0].tag // value is 2
b[0].tag // value is 2?
Aucun commentaire:
Enregistrer un commentaire