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 *'
As Wain said there is no convenient method to convert from PFGeoPoint to a CLLocation however you can make your own and extend PFGeoPoint using the following 
import Parse
extension PFGeoPoint {
    func location() -> CLLocation {
        return CLLocation(latitude: self.latitude, longitude: self.longitude)
    }
}
now you can easily return a CLLocation object by doing
let aLocation: CLLocation = yourGeoPointObject.location()
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.
Based on Justin Oroz's answer (see the answer below): Also a great idea could be to create the extension in the CLLocation side so it can be created using a convenience init which receives the PFGeoPoint:
extension CLLocation {
    convenience init(geoPoint: PFGeoPoint) {
        self.init(latitude: geoPoint.latitude, longitude: geoPoint.longitude)
    }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With