2012-07-05 2 views
0

에 CLLocationCoordinate2D을 할당 할 수 없습니다 : 내가 잘못 뭐하는 거지나는 다음과 같은 오류 얻고 다른 CLLocationCoordinate2D

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]; 
      [email protected]"Your Property Listing"; 
      locationMapViewController.centerOfMap = coordinate; 
      [self.navigationController pushViewController:locationMapViewController animated:YES]; 


     } 
    }]; 


} 

: 아래의 다음 줄에

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

를?

답변

4

오류가 발생했습니다. CLLocationCoordinate2D 값 (NO POINTER 참조)을 포인터 (CLLocationCoordinate2D *)에 할당하고 있습니다. &을 사용하여 변수의 주소를 가져올 수 있습니다. pointer라고도합니다. 따라서 locationMapViewController.centerOfMap = &coordinate;을 수행하거나 latitudelongitude 값을 직접 설정할 수 있습니다.

건배,

조지