gpt4 book ai didi

ios - 如何发送坐标进行解析并将其保存为解析PFGeopoint

转载 作者:行者123 更新时间:2023-12-01 18:52:05 27 4
gpt4 key购买 nike

如何将坐标发送到CLLocation提取的解析并将其保存为PFGeoPoint的纬度和经度?

我可以从CLLocation获取坐标,我想将其发送到Parse。在Parse中,我有一列名为PFGeoPoint类型的“coordinates”,其中有两个字段。现在,我要将从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
    }
    }];
  • 关于ios - 如何发送坐标进行解析并将其保存为解析PFGeopoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30435362/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com