Sunday, 11 August 2013

Why is this CLLocationCoordinate2D variable unassignable?

Why is this CLLocationCoordinate2D variable unassignable?

I have a geocoder method and I want it to return the
CLLocationCoordinate2D that it generates for me.
- (CLLocationCoordinate2D)geocode{
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(0,0);
[geocoder geocodeAddressDictionary:self.placeDictionary
completionHandler:^(NSArray *placemarks, NSError *error) {
if([placemarks count]) {
CLPlacemark *placemark = [placemarks objectAtIndex:0];
CLLocation *location = placemark.location;
coordinate = location.coordinate;
} else {
NSLog(@"error");
}
}];
return coordinate;
}
The line coordinate = location.coordinate produces an error however. XCode
says coordinate is an unassignable variable. Anyone see what I'm doing
wrong?

No comments:

Post a Comment