2010-05-03 86 views
0

我遇到了一些神秘的bug(对我来说)。我有一些代码在iPhone SDK上挑选用户的当前位置。它在iPhone模拟器上工作正常,但是当我尝试在实际设备上运行它时,出现奇怪的错误。可以从iPhone模拟器获得坐标,但无法从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上,它没有。

更奇怪的是,当我通过与设备上的调试器,我尝试“宝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. 

你们有什么想法,为什么会发生这种情况?在此先感谢您的帮助!

回答

1

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

+0

嗯......这是真的,但NSLog仍然没有记录纬度和经度... – iPhoneARguy 2010-05-03 03:31:02