gpt4 book ai didi

ios - 从 Cllocation 获取 CLLocationCorrdinate2D 时出错

转载 作者:行者123 更新时间:2023-11-29 02:11:56 25 4
gpt4 key购买 nike

我正在尝试从 CLLocation 对象获取 CLLocationCooperative2D。我正在使用以下代码,它是通过 NSNotification 调用的:

-(void)setMapCenterWith:(CLLocation*)location {
CLLocationCoordinate2D coord = location.coordinate;
[self moveToCoordinate:coord];
}

我已验证传入的位置对象有效并且包含位置。但是,当调用包含 location.coordinate 的行时,应用程序崩溃并出现以下错误:

[NSConcreteNotification coordinate]: unrecognized selector sent to instance

这是位置对象上的日志输出:

NSConcreteNotification 0x798988e0 {name = PPTFormSubmittedWithLocation; object = <+38.05230000,-81.10880000> +/- 5.00m (speed -1.00 mps / course -1.00) @ 3/22/15, 12:35:34 PM Eastern Daylight Time}

知道为什么会发生这种情况吗?谢谢!

最佳答案

setMapCenterWithNSNotificationCenter 调用,这意味着它需要将 NSNotification 作为参数:

-(void)setMapCenterWith:(NSNotification *)notif

看起来通知的对象是您感兴趣的CLLocation,因此您需要将方法更改为:

-(void)setMapCenterWith:(NSNotification *)notif {
CLLocation *location = notif.object;
CLLocationCoordinate2D coord = location.coordinate;
[self moveToCoordinate:coord];
}

关于ios - 从 Cllocation 获取 CLLocationCorrdinate2D 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29196939/

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