[英]how to get old location from corelocation
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
位置数组最后一个对象保存新位置,如何获取以前的位置?
您应该创建并使用一个可变数组,其中包含从先前调用“ locationManager: didUpdateLocations:
”更新的先前locationManager: didUpdateLocations:
。
根据 Apple 文档,唯一一次通过委托方法传入的“ locations
”数组将有多个条目是“如果更新事件被推迟,或者如果多个事件在传递之前到达,则该数组可能包含额外的条目。”
在此方法中获取更新的位置
func locationManager(_ manager: CLLocationManager,didUpdateLocations locations: [CLLocation])
{
guard let mostRecentLocation = locations.last else { return }
print(mostRecentLocation)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.