Kimberly Kimberly - 1 year ago 111
Objective-C Question

How to convert PFGeoPoint to CLLocation

Is it possible to convert the PFGeoPoint with Parse to a CLLocation?

Reason being I'm trying to get the names of places from PFGeoPoint like so:

CLGeocoder *geocoder;
CLPlacemark *placemark;
PFGeoPoint *point = [object objectForKey:@"location"];
[geocoder reverseGeocodeLocation:point completionHandler:^(NSArray *placemarks, NSError *error) {
NSLog(@"Found placemarks: %@, error: %@", placemarks, error);
if (error == nil && [placemarks count] > 0)
placemark = [placemarks lastObject];
NSLog(@"%@", placemarks);


Error I get obviously is:

Incompatiable pointer types sending 'PFGeoPoint *' to parameter of type 'CLLocation *'


You need to explicitly create the CLLocation instance using initWithLatitude:longitude: with the latitude and longitude from the PFGeoPoint. There is only a convenience method for creating a PFGeoPoint from a CLLocation, not the other way round.