I have an NSMutableDictionary that I make copies of. After I make the copies I want to change the values in each dictionary independently. However, when I change one all the others change. It's almost like the copies are just pointers back to the original. My code to set them is:
var nf = text?.toInt()!
var creatureInfo = NSMutableDictionary()
for var c = 0;c<nf;c++ {
creatureInfo = NSMutableDictionary()
creatureInfo = getCreature(name)
creatureInfo.setValue("creature", forKey: "combat-type")
combatants.append(creatureInfo)
}
I thought at doing creatureInfo = NSMutableDictionary() in the loop would work but it did not.
Aucun commentaire:
Enregistrer un commentaire