Iphone CLLocation获取EXC\u错误\u访问
我在尝试访问CLLocation时出错,您能解释一下原因吗Iphone CLLocation获取EXC\u错误\u访问,iphone,mkmapview,Iphone,Mkmapview,我在尝试访问CLLocation时出错,您能解释一下原因吗 CLLocation *currentLocation; @property (nonatomic, retain) CLLocation *currentLocation; 我正在从位置经理那里获得位置反馈: - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(
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);
}
}
位置经理:+/-100.00m(速度-1.00mps/航向-1.00)@9/2/11 10:14:58
π.μ. 格林尼治时间+02:00
但当我试图从DidSelectAnnotationView访问currentLocation时,我获得了EXC\u BAD\u访问权限:
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
NSLog(@"current Location: %@", currentLocation);
}
你能解释一下为什么我不能访问它吗
非常感谢 您没有保留该位置。像这样做:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
if (newLocation != nil) {
self.currentLocation = newLocation; /// The change is here
NSLog(@"locationManager: %@", currentLocation);
}
}
您没有保留该位置。像这样做:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
if (newLocation != nil) {
self.currentLocation = newLocation; /// The change is here
NSLog(@"locationManager: %@", currentLocation);
}
}