Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用ios parse.com将坐标保存为PFGeopoint_Ios_Swift_Parse Platform_Coordinate Systems - Fatal编程技术网

如何使用ios parse.com将坐标保存为PFGeopoint

如何使用ios parse.com将坐标保存为PFGeopoint,ios,swift,parse-platform,coordinate-systems,Ios,Swift,Parse Platform,Coordinate Systems,我想添加使用textfield的用户提供的经度和纬度,以及要在PFGeoPoint中传递的值。但是textfield值在字符串中,与PFGeoPoint无关。我的代码是: @IBOutlet weak var latitue_filed: UITextField! @IBOutlet weak var longitudead: UITextField! let lati : = (latitue_filed.text as? PFGeoPoint)! let lon : = (

我想添加使用textfield的用户提供的经度和纬度,以及要在PFGeoPoint中传递的值。但是textfield值在字符串中,与PFGeoPoint无关。我的代码是:

@IBOutlet weak var latitue_filed: UITextField!
@IBOutlet weak var longitudead: UITextField!

   let lati :  = (latitue_filed.text as? PFGeoPoint)!
   let lon :  = (longitudead.text as? PFGeoPoint)!

  let myGeoPoint = PFGeoPoint(latitude: lat, longitude: lon)
    posts["location"] = myGeoPoint
    posts.saveInBackgroundWithBlock {
        (success: Bool, error: NSError?) -> Void in
        if (success) {
            // The object has been saved.
        } else {
            // There was a problem, check error.description
        }
    }
    posts.saveInBackground()` 
这里是latitue_字段,longitudead是textfield。如何在PFGeoPoint中传递文本字段值。

根据,
PFGeoPoint
实际上是一个
PFObject
,它使用双倍的
纬度
经度
(即度)并将它们嵌入在一起。您当前正在将字符串值从textfield强制转换为单个
PFGeoPoints
。将字符串值强制转换为双倍,并使用文档中描述的方法创建
PFGeoPoint

let lati = Double(latitue_filed.text)
let lon = Double(longitudead.text)

let myGeoPoint = PFGeoPoint(latitude: lat, longitude: lon)
posts["location"] = myGeoPoint
posts.saveInBackgroundWithBlock {
    (success: Bool, error: NSError?) -> Void in
    if (success) {
        // The object has been saved.
    } else {
        // There was a problem, check error.description
    }
}