CLLocation 获取 EXC_BAD_ACCESS
我在尝试访问 CLLocation 时遇到错误,您能解释一下原因吗?
CLLocation *currentLocation;
@property (nonatomic, retain) CLLocation *currentLocation;
我从位置经理处收到有关该位置的反馈:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
if (newLocation != nil) {
currentLocation = newLocation;
NSLog(@"locationManager: %@", currentLocation);
}
}
位置经理:<+36.45307493, +28.22220462> +/- 100.00m(速度 -1.00 mps/航向 -1.00)@ 9/2/11 10:14:58 π.μ。 GMT+02:00
但是当我尝试从 DidSelectAnnotationView 访问 currentLocation 时,我得到 EXC_BAD_ACCESS:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
NSLog(@"current Location: %@", currentLocation);
}
您能解释一下为什么我无法访问它吗?
非常感谢!
I am getting an Error when trying to access a CLLocation, can you please explain why?
CLLocation *currentLocation;
@property (nonatomic, retain) CLLocation *currentLocation;
I am geeting feedback for the location from the location manager:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
if (newLocation != nil) {
currentLocation = newLocation;
NSLog(@"locationManager: %@", currentLocation);
}
}
locationManager: <+36.45307493,
+28.22220462> +/- 100.00m (speed -1.00 mps / course -1.00) @ 9/2/11 10:14:58
π.μ. GMT+02:00
but when I am trying to access currentLocation from DidSelectAnnotationView i get the EXC_BAD_ACCESS:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
NSLog(@"current Location: %@", currentLocation);
}
can you please explain why I cannot access it?
Many Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不会保留该位置。这样做:
You are not retaining the location. Do it like: