Can get coordinates from iPhone simulator, but can't get coordinates from iPhone device

Posted by iPhoneARguy on Stack Overflow See other posts from Stack Overflow or by iPhoneARguy
Published on 2010-05-03T02:55:09Z Indexed on 2010/05/03 2:58 UTC
Read the original article Hit count: 642

Hi everyone,

I've run into something of a mysterious bug (to me). I have some code to pick out the user's current location on the iPhone SDK. It works fine on the iPhone simulator, but when I try to run it on the actual device, I get a weird error.

Here is the code (I am using ASIFormDataRequest to create a POST request):

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"];

On the simulator, NSLog does log both the latitude and longitude, but on the iPhone, it does not.

Even stranger, when I go through with the debugger on the device, I try "po datum.location", I get

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

(### replaced by my location) but when I do "(gdb) po datum.location.coordinate" I get:

There is no member named coordinate.

Do you guys have any idea why this might happen? Thanks in advance for your help!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c