简体   繁体   中英

Covert CLLocation to PFGeoPoint with Swift

Is there an example of the swift implementation of the constructor +geoPointWithLocation?

https://parse.com/docs/ios/api/Classes/PFGeoPoint.html#//api/name/geoPointWithLocation :

current attempt:

    self.locationManager.delegate = self
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
    self.locationManager.requestWhenInUseAuthorization()
    self.locationManager.startUpdatingLocation()

    var currentLoc = CLLocationManager()
    currentGeoPoint = PFGeoPoint(geoPointWithLocation(currentLoc))

I haven't used this framework, but... Try PFGeoPoint(location: currentLoc) .

Generally, when you have an ObjC factory method call like +[NSFooBar fooBarWithBaz:] , it imports as the Swift initializer init(baz:) .

Oh, and it looks like you need to actually get a location from your CLLocationManager , not just pass the manager to PFGeoPoint .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM