如何发送坐标进行解析并将其保存为解析 PFGeopoint
how can I send coordinates to parse and save it as parse PFGeopoint
如何将 CLLocation 获取的坐标发送到 Parse,并将其保存为 PFGeoPoint 的经纬度?
我能够从 CLLocation 获取坐标,我想将其发送到 Parse。在 Parse 中,我有一个名为 "coordinates" 的 PFGeoPoint 类型的列,它有两个 fields.Now 我想将从 CLLocation 获得的坐标保存到 Parse Column 坐标。
谁能帮我解决这个问题?
我是 iOS 和 Parse 的新手。
两步:
将 CLLocation 转换为 PFGeoPoint
//SWIFT
let point = PFGeoPoint(location: currentLoc)
//Obj-c
[PFGeoPoint *point = PFGeoPoint geoPointWithLocation:(PF_NULLABLE CLLocation *)location];
现在保存。
//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
}
}];
如何将 CLLocation 获取的坐标发送到 Parse,并将其保存为 PFGeoPoint 的经纬度?
我能够从 CLLocation 获取坐标,我想将其发送到 Parse。在 Parse 中,我有一个名为 "coordinates" 的 PFGeoPoint 类型的列,它有两个 fields.Now 我想将从 CLLocation 获得的坐标保存到 Parse Column 坐标。 谁能帮我解决这个问题? 我是 iOS 和 Parse 的新手。
两步:
将 CLLocation 转换为 PFGeoPoint
//SWIFT let point = PFGeoPoint(location: currentLoc) //Obj-c [PFGeoPoint *point = PFGeoPoint geoPointWithLocation:(PF_NULLABLE CLLocation *)location];
现在保存。
//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 } }];