gpt4 book ai didi

ios - didUpdateLocations 而不是 didUpdateToLocation

转载 作者:IT老高 更新时间:2023-10-28 11:26:48 29 4
gpt4 key购买 nike

随着 iOS6 的发布,Apple 希望我们使用 didUpdateLocations 而不是 didUpdateToLocation。谁能解释一下如何正确使用 didUpdateLocations?

最佳答案

我假设您使用以下委托(delegate)来获得最后一个位置?

- (void)locationManager:(CLLocationManager *)manager 
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation

上面的委托(delegate)在 iOS 6 中已被弃用。现在应该使用以下代理:

- (void)locationManager:(CLLocationManager *)manager 
didUpdateLocations:(NSArray *)locations

为了获取最后的位置,只需获取数组的最后一个对象:

[locations lastObject]

换句话说,[locations lastObject](新委托(delegate))等于 newLocation(旧委托(delegate))。

关于ios - didUpdateLocations 而不是 didUpdateToLocation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12602463/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com