我有一个方法用于在地图上设置和显示注释:
func setupPlacemark(place: Place, mapView: MKMapView) {
guard let location = place.location else { return }
let geocoder = CLGeocoder()
geocoder.geocodeAddressString(location) { [unowned self] (placemarks, error) in
if let error = error {
print(error)
return
}
guard let placemarks = placemarks else { return }
let placemark = placemarks.first
let annotation = MKPointAnnotation()
annotation.title = place.name
annotation.subtitle = place.type
guard let placemarkLocation = placemark?.location else { return }
annotation.coordinate = placemarkLocation.coordinate
self.placeCoordinate = placemarkLocation.coordinate
mapView.showAnnotations([annotation], animated: true)
mapView.selectAnnotation(annotation, animated: true)
}
}
当我运行泄漏工具时,我看到了这个泄漏:
在这里你会看到哪一行代码不喜欢:
我应该怎么做才能使这种泄漏消失?