I am creating an app, that should display a route between two points.
MKPolyline *routeLine = [MKPolyline polylineWithCoordinates:locations count:2];
[mapView addOverlay:routeLine];
The two locations are stored in the array "locations".
I am getting an error
Implicit conversion of Objective-C pointer type 'NSMutableArray *' to C pointer type 'CLLocationCoordinate2D *' requires a bridged cast
Please help me over this.
Thanks in advance.
This method requires a parameter of type CLLocationCoordinate2D array. You will have to make an array of type CLLocationCoordinate2D. Code will look some kind of this:
CLLocationCoordinate2D *coordsArray = malloc(sizeof(CLLocationCoordinate2D) * locations.count);
int i = 0;
for (CLLocation *loc in locations) {
coordsArray[i] = loc.coordinate;
i++;
}
MKPolyline * routeLine = [MKPolyline polylineWithCoordinates:coordsArray
count:locations.count];
free(coordinateArray);
[mapView addOverlay:routeLine];