Set variable (reference) from dictionary to new value

42 views Asked by At

How can i change the value of a variable that is referenced in a dictionary.

func setApiItem(name: String, setTo: String) {
    var refs = [
        "apiKey" : self.apiKey,
        "shipmentHost": self.shipmentHost,
        "shipmentPrinter": self.shipmentPrinter,
        "shipmentFormat": self.shipmentFormat,
        "orderHost": self.orderHost,
        "orderPrinter": self.orderPrinter,
        "orderFormat": self.orderFormat
    ]
    
    refs[name] = setTo // Don't work, won't change the variable value.
}

Im well aware self.apiKey = setTo would change the value, but how can i achieve this when the variable is stored in the dictionary?

0

There are 0 answers