Jak dodać parę wartości klucza do słownika w języku swift
Przykłady kodu
6
0
tworzenie słownika swift
var someDict:[String:Int] = ["One":1, "Two":2, "Three":3] // creates dictionary
var someVar = someDict["One"] // accesses the value of key "One"
print("The value of key = One is \(someVar)")
0
0
słownik swift pobierz klucz od valye
let dict: [Int: String] = [1: "one", 2: "two", 4: "four"]
if let key = dict.someKey(forValue: "two") {
print(key)
} // 2