Ios 如何在Swift中循环mapView.Annotations?

Ios 如何在Swift中循环mapView.Annotations?,ios,objective-c,swift,Ios,Objective C,Swift,无法将此行目标C代码转换为Swift for (id <MKAnnotation> annotation in mapView.annotations) { // Do Something } 或 我得到:预期';'在“for”语句中 谢谢 答案如下: for annotation in mapView.annotations as [MKAnnotation] {...} 你有什么问题?您是否遇到编译错误?您尝试过什么?尝试过:for(注释:mapView.annota

无法将此行目标C代码转换为Swift

for (id <MKAnnotation> annotation in mapView.annotations) {
    // Do Something
}

我得到:预期';'在“for”语句中

谢谢

答案如下:

for annotation in mapView.annotations as [MKAnnotation] {...}

你有什么问题?您是否遇到编译错误?您尝试过什么?尝试过:
for(注释:mapView.annotations中的MKannotation)
for mapView.annotations中的注释{…}
@zisoft当我尝试您的建议时,我得到了预期的相同编译错误“;”在“for”语句中,这应该是mapView.annotations中的注释![MKAnnotation]这也应标记为正确答案:)
for (annotation in mapView.annotations)
for annotation in mapView.annotations as [MKAnnotation] {...}