如何从corelocation获得旧位置 [英] how to get old location from corelocation

查看:52
本文介绍了如何从corelocation获得旧位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

- (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:".

根据Apple文档,唯一通过委托方法传递的 位置数组将只有一个以上的条目将为如果推迟了更新事件,或者如果在交付之前有多个事件到达,则阵列可能会污染在其他条目中。

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获得旧位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆