Answers for "how to add key value pair inside Dictionary in swift"

6

create dictionary 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)")
Posted by: Guest on June-16-2020
0

swift dictionary get key from valye

let dict: [Int: String] = [1: "one", 2: "two", 4: "four"]

if let key = dict.someKey(forValue: "two") { 
    print(key)
} // 2
Posted by: Guest on October-15-2020

Code answers related to "how to add key value pair inside Dictionary in swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language