【发布时间】:2019-07-09 20:30:37
【问题描述】:
我一直在努力实现这段代码。我正在将一些遗留代码转换为 swift,但我无法让 [annotation isKindofClass] 等价物工作。
最初我选择了类似的东西(给了我错误
mapView.annotations.forEach {
if !$0.isKind(of: MKUserLocation) {
self.mapView.removeAnnotation($0)
}
}
但我在this 帖子上读到 swift 有不同的处理方式。
mapView.annotations.forEach {
if !$0 is MKUserLocation {
self.mapView.removeAnnotation($0)
}
}
这给了我错误:无法将 MKAnnotation 类型的值转换为预期的参数类型 BOOL
【问题讨论】: