如何在Swift中循环mapView.Annotations?

BX6*_*X69 2 objective-c ios swift

将此系列Objective C代码转换为Swift时遇到问题

for (id <MKAnnotation> annotation in mapView.annotations) {
    // Do Something
}
Run Code Online (Sandbox Code Playgroud)

当我尝试:

for (annotation:MKannotation in mapView.annotations)
Run Code Online (Sandbox Code Playgroud)

要么

for (annotation in mapView.annotations)
Run Code Online (Sandbox Code Playgroud)

我明白了:'期待';' 在'for'声明中

谢谢!!

BX6*_*X69 10

这是答案:

for annotation in mapView.annotations as [MKAnnotation] {...}
Run Code Online (Sandbox Code Playgroud)