iphone模拟器在尝试访问用户位置时崩溃

时间:2010-06-18 01:57:43

标签: objective-c iphone-sdk-3.0 core-location

由于某种原因,我的代码导致我的程序崩溃。有谁知道为什么或如何解决它?

NSLog(@"here");
CLLocation *location = [locationManager location]; 
[mapView removeAnnotations:mapView.annotations]; 
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
CLLocationCoordinate2D workingCoordinate = [location coordinate];
 NSLog(@" this is %@", workingCoordinate.latitude);

它使它成为第一个NSLog,但它在第一个和第二个之间的某个地方崩溃了。我的猜测是它与CLLocation *位置线有关。

1 个答案:

答案 0 :(得分:2)

CLLocationCoordinate2D是一个包含两个类型为CLLocationDegrees的非对象字段的结构。传递给%@的{​​{1}}会尝试将该值解释为对象引用,这会导致崩溃。

尝试:     NSLog(@“这是%d”,workingCoordinate.latitude);

相关问题