To iterate over a dictionary in Swift, you can use a for-in loop with the Dictionary
type's keys
and values
properties, as well as its enumerated()
method for accessing key-value pairs with their respective index.
Here is an example code snippet:
main.swift371 chars17 lines
This would output:
main.swift153 chars10 lines
gistlibby LogSnag