[英]Unable to assign a CLLocationCoordinate2D to another CLLocationCoordinate2D
I am getting the following error: 我收到以下错误:
Assigning to 'CLLocationCoordinate2D *' from incompatible type 'CLLocationCoordinate2D'; take the address with &
At the following line below: 在下面的行中:
locationMapViewController.centerOfMap = coordinate;
- (IBAction) btnLocateAddress
{
if (!self.geocoder) {
self.geocoder = [[CLGeocoder alloc] init];
}
[self.geocoder geocodeAddressString:self.address.text completionHandler:^(NSArray *placemarks, NSError *error) {
if ([placemarks count] > 0) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
CLLocation *location = placemark.location;
CLLocationCoordinate2D coordinate = location.coordinate;
self.address.text = [NSString stringWithFormat:@"%f, %f", coordinate.latitude, coordinate.longitude];
if ([placemark.areasOfInterest count] > 0) {
NSString *areaOfInterest = [placemark.areasOfInterest objectAtIndex:0];
NSLog(@"Area of Interest: %@",areaOfInterest);
}
//lets push the new map screen
LocationMapViewController *locationMapViewController = [[LocationMapViewController alloc] initWithNibName:@"LocationMapViewController_iPhone" bundle:nil];
locationMapViewController.title=@"Your Property Listing";
locationMapViewController.centerOfMap = coordinate;
[self.navigationController pushViewController:locationMapViewController animated:YES];
}
}];
}
What am I doing wrong? 我究竟做错了什么?
The error tells you all. 错误告诉大家。 You are assigning a
CLLocationCoordinate2D
value (see NO POINTER) to a pointer ( CLLocationCoordinate2D *
) You can use & to get the adress of a variable. 您正在将
CLLocationCoordinate2D
值(请参见NO POINTER)分配给指针( CLLocationCoordinate2D *
)。可以使用&获取变量的地址。 Also known as pointer
. 也称为
pointer
。 So you can either do locationMapViewController.centerOfMap = &coordinate;
因此,您可以执行
locationMapViewController.centerOfMap = &coordinate;
or set the latitude
and longitude
values directly. 或直接设置
latitude
和longitude
值。
Cheers, 干杯,
George 乔治
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.