14.14 Dictionary Iteration
As with arrays, it is possible to iterate through dictionary entries by making use of the for-in looping syntax. The following code, for example, iterates through all of the entries in the books dictionary, outputting both the key and value for each entry:
for (bookid, title) in bookDict {
print("Book ID: \(bookid) Title: \(title)")
}
Upon execution, the following output would appear in the console:
Book ID: 100-432112 Title: Wind in the Willows
Book ID: 200-532874 Title: The Ruins
Book ID: 104-109834 Title: Shutter Island
Book ID: 202-546549 Title: Sense and Sensibility