reverseGeocodeLocation(_ location: CLLocation) 方法是否在离线模式下工作?

Does reverseGeocodeLocation(_ location: CLLocation) method works in offline mode?

我正在从方法 reverseGeocodeLocation(_ location: CLLocation) 中获取位置名称。我的要求是在离线模式下将 Lat-Long 值存储在数据库中,我还想存储从上述方法获得的位置名称字符串。 这是我实施的:

geoCoder.reverseGeocodeLocation(location, completionHandler: { (placemarks, error) in
            
  let place = placemarks?[0]
  var countryName = ""
            
  if let countryString = place?.country {
       countryName = countryString
  }

我在离线模式下绝对可以获取经纬度;我的问题是,上述方法是否也适用于 离线模式

正如 the documentation 所说(强调):

This method submits the specified location data to the geocoding server asynchronously and returns.

由于它是将请求发送到服务器,如果离线,您几乎肯定无法获得反向地理编码响应。

但是您可以将坐标添加到一些持久存储中,当您重新联机时应该能够对它们进行反向地理编码。但是,如果您这样做,请记住它们是有速率限制的。正如文档继续说的那样:

Geocoding requests are rate-limited for each app, so making too many requests in a short period of time may cause some of the requests to fail. When the maximum rate is exceeded, the geocoder passes an error object with the value CLError.Code.network to your completion handler.