gpt4 book ai didi

ios - 无法将 CLLocationCoordinate2D 分配给另一个 CLLocationCoordinate2D

转载 作者:行者123 更新时间:2023-11-28 19:17:11 25 4
gpt4 key购买 nike

我收到以下错误:

Assigning to 'CLLocationCoordinate2D *' from incompatible type 'CLLocationCoordinate2D'; take the address with &

在下面一行:

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


}
}];


}

我做错了什么?

最佳答案

错误告诉你一切。您正在将 CLLocationCoordinate2D 值(请参阅 NO POINTER)分配给指针 ( CLLocationCoordinate2D * ) 您可以使用 & 获取变量的地址。也称为 pointer 。因此,您可以执行 locationMapViewController.centerOfMap = &coordinate; 或直接设置 latitudelongitude 值。

干杯,

乔治

关于ios - 无法将 CLLocationCoordinate2D 分配给另一个 CLLocationCoordinate2D,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11353508/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com