使用Swift将CLLocation转换为GeoPoint

时间:2014-12-28 04:33:59

标签: objective-c xcode swift parse-platform

是否有一个快速实现构造函数+ geoPointWithLocation的示例?

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

目前的尝试:

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

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

1 个答案:

答案 0 :(得分:2)

我没有使用过这个框架,但是......尝试PFGeoPoint(location: currentLoc)

通常,当您使用像+[NSFooBar fooBarWithBaz:]这样的ObjC工厂方法调用时,它会作为Swift初始值设定项init(baz:)导入。

哦,看起来您需要从CLLocationManager实际获取位置,而不仅仅是将经理传递给PFGeoPoint