1 year ago
#370834
haveman
Set variable (reference) from dictionary to new value
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?
swift
nsdictionary
0 Answers
Your Answer