如何在Swift 5中遍历字典?

Nic*_* S. 0 swift swift5

在Swift 4中,下面的代码可以工作,但是在Swift 5中,出现以下错误: Type 'Dictionary<String, String>.Values.Iterator' does not conform to protocol 'Sequence'

guard let userIds = users.values.makeIterator() else { return }

for userId in userIds {
    // User setup
}
Run Code Online (Sandbox Code Playgroud)

Swift 5现在正确的方法是什么?

iDe*_*vid 5

let dictionary: [String: Int] = ["a": 1, "b": 2]

for (key, value) in dictionary {
    print(key, value)
}
Run Code Online (Sandbox Code Playgroud)