【问题标题】:Can get coordinates from iPhone simulator, but can't get coordinates from iPhone device可以从 iPhone 模拟器获取坐标,但无法从 iPhone 设备获取坐标
【发布时间】:2011-02-14 21:38:59
【问题描述】:

我遇到了一个神秘的错误(对我来说)。我有一些代码可以在 iPhone SDK 上挑选出用户的当前位置。它在 iPhone 模拟器上运行良好,但是当我尝试在实际设备上运行它时,我得到一个奇怪的错误。

这里是代码(我正在使用 ASIFormDataRequest 创建一个 POST 请求):

ASIFormDataRequest * request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"testauthor" forKey:@"author"];
[request setPostValue:[[NSNumber numberWithDouble:datum.location.coordinate.latitude] stringValue] forKey:@"latitude"];
NSLog(@"%f", datum.location.coordinate.latitude);
NSLog(@"%f", datum.location.coordinate.longitude);
[request setPostValue:[[NSNumber numberWithDouble:datum.location.coordinate.longitude] stringValue] forKey:@"longitude"];
[request setPostValue:datum.comment forKey:@"comment"];

在模拟器上,NSLog 会同时记录纬度和经度,但在 iPhone 上却没有。

即使是陌生人,当我在设备上使用调试器时,我尝试“po datum.location”,我得到了

<+###, -###> +/- 223.10m (speed 0.00 mps / course -1.00) @ 2010-05-02 22:18:37 -0400

(### 替换为我的位置)但是当我执行“(gdb)po datum.location.coordinate”时,我得到:

There is no member named coordinate.

你们知道为什么会发生这种情况吗?提前感谢您的帮助!

【问题讨论】:

    标签: iphone objective-c cllocationmanager


    【解决方案1】:

    因为po 打印一个对象,而CLLocationCoordinate2D 不是对象,它是一个结构体。

    【讨论】:

    • 嗯...确实如此,但是 NSLog 似乎仍然没有记录纬度和经度...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-26
    • 1970-01-01
    • 2011-05-11
    • 1970-01-01
    • 2012-07-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多