ios8 - Swift use String as Dictionary Keys -
i don't know if possible ... have code
var dic = dictionary<string, string>() var string = [button1, button2, button3] @ibaction func button(sender: anyobject){ dic["\(string)"] = "0" }
the result in dic
[button1, button2, button3]:0
but want :
[button1:0, button2:0, button3:0]
how can do?
from apple swift dpcs example doc:
var airports: [string: string] = ["yyz": "toronto pearson", "dub": "dublin"]
this definitly, access:
var key = "dub" var val = airports[key] var val2 = airports["dub"]
means have use steink directly access value :-)
Comments
Post a Comment