Hope this example I just coded helps:
func requestPlacemark() async -> CLPlacemark? {
let geocoder = CLGeocoder()
return await withTaskCancellationHandler {
geocoder.cancelGeocode()
} operation: {
await withCheckedContinuation { continuation in
geocoder.reverseGeocodeLocation(location) { placemarks, error in
continuation.resume(returning: placemarks?.first)
}
}
}
}
Next I plan on handling the returned error, likely converting it to a throw.