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

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

本文介绍了如何发送坐标进行解析并将其保存为解析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.

推荐答案

两步:


  1. 将CLLocation转换为PFGeoPoint

  1. 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    07-28 03:47