如何发送坐标进行解析并将其保存为解析 PFGeopoint [英] how can I send coordinates to parse and save it as parse PFGeopoint
问题描述
如何将坐标发送到由 CLLocation 获取的 Parse 并将其保存为 PFGeoPoint 的纬度和经度?
How can i send coordinates to Parse fetched by CLLocation and save it there as PFGeoPoint's latitude and longitude?
我能够从 CLLocation 获取坐标,我想将其发送到 Parse.在 Parse 中,我有一列名为坐标"的 PFGeoPoint 类型,它有两个字段.现在我想保存从 CLLocation 获得的坐标到 Parse Column 坐标.任何人都可以帮我解决这个问题吗?我是 iOS 和 Parse 的新手.
I am able to get the coordinates from CLLocation and I want to send it to Parse. In Parse I have a column named "coordinates" of type PFGeoPoint which has two fields.Now I want to save the coordinates which I have got from CLLocation to Parse Column coordinates. can anyone please help me with this? I am new to iOS and Parse.
推荐答案
两步:
将 CLLocation 转换为 PFGeoPoint
Convert CLLocation to PFGeoPoint
//SWIFT
let point = PFGeoPoint(location: currentLoc)
//Obj-c
[PFGeoPoint *point = PFGeoPoint geoPointWithLocation:(PF_NULLABLE CLLocation *)location];
现在保存.
Now save it.
//SWIFT
object["coordinates"] = point
object.saveInBackgroundWithBlock {
(success: Bool, error: NSError?) -> Void in
if (success) {
// The object has been saved.
} else {
// There was a problem, check error.description
}
}
//Obj-c
object["coordinates"] = point;
[object saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
// The object has been saved.
} else {
// There was a problem, check error.description
}
}];
这篇关于如何发送坐标进行解析并将其保存为解析 PFGeopoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!