Loop through dictionary

 Problem

I have a Dictionary and want to iterate through all of its elements.



 Recipe


// Initialize the Dictionary
let dict = ["name": "John", "surname": "Doe"]
 
// Iterate through the dictionary

for (key,value) in dict { 
    print("\(key) = \(value)")
}
				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground