将CLLocationCoordinate2D转换为PFGeoPoint?

dur*_*zno 1 objective-c ios parse-platform geopoints cllocationcoordinate2d

我使用CLLocationCoordinate2D获取用户的当前位置,然后将其用于Parse的nearGeoPoint.

我知道我可以简单地使用geoPointForCurrentLocationInBackground但我宁愿用CLLocationCoordinate2D检索.

tul*_*dev 5

您可以使用geoPointWithLatitude:longitude:PFGeoPoint类的初始化程序.给它CLLocationCoordinate2D的纬度和经度值,你就会得到你的PFGeoPoint.

例如

PFGeoPoint *geoPoint = [PFGeoPoint geoPointWithLatitude:coordinate.latitude longitude:coordinate.longitude];
Run Code Online (Sandbox Code Playgroud)