问题描述
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
locations数组的最后一个对象拥有新位置,如何获取上一个位置?
locations array last object holds new location, How to get the previous location?
推荐答案
您应该创建并使用一个可变的先前位置数组,这些位置是从先前对 locationManager:didUpdateLocations:
的调用中更新的。
You should create and use a mutable array of previous locations that were updated from previous calls to "locationManager: didUpdateLocations:
".
,唯一通过委托方法传递的 位置
数组将只有一个以上的条目将为如果推迟了更新事件,或者如果在交付之前有多个事件到达,则阵列可能会污染在其他条目中。
According to the Apple documentation, the only time that "locations
" array passed in via the delegate method will have more than one entry will be "If update events were deferred or if multiple events arrived before they could be delivered, the array may contain additional entries."
这篇关于如何从corelocation获得旧位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!