我想在解析服务器中使用以下代码保存PFGeoPoint:
var coordinates = PFGeoPoint (latitude: (newCoordinate2.latitude), longitude:(newCoordinate2.longitude))
var aboutSpot = PFObject(className: "spotdetail")
aboutSpot["name"] = "name"
aboutSpot [PFGeoPoint] = coordinates
aboutSpot.saveInBackgroundWithBlock { (succes, error) -> Void in
print("separate name and geopoint have been saved")
}
我收到以下消息:
swift cannot convert value of type `(PFGeoPoint).type (aka 'PFGeoPoint.type`) to expected argument type 'String'
我可以更改什么,以便Xcode不再认为我正在尝试保存字符串?
答案 0 :(得分:0)
首先尝试将经度和纬度转换为double
,然后使用distanceInKilometersTo
或distanceInMilesTo
。
希望这有帮助。
答案 1 :(得分:0)
我想通了,所以我在解析服务器中手动添加了一列,然后更改了这样的代码,它现在可以正常工作了,谢谢你的帮忙
var coordinates = PFGeoPoint (latitude: (newCoordinate2.latitude), longitude:(newCoordinate2.longitude))
var aboutSpot = PFObject(className: "spotdetail")
aboutSpot["name"] = "replaceNow"
aboutSpot ["PFGeoPoint"] = coordinates
aboutSpot.saveInBackgroundWithBlock { (succes, error) -> Void in
print("separate name and geopoint have been saved")
}