小编Ish*_*ain的帖子

如何将字符串转换为 CLLocationDegrees Swift 2

我正在尝试转换从 Firebase 检索的字符串,并将其添加为 Google 地图上的多个注释。不幸的是,我的应用程序在通过当前代码时崩溃:

ref = FIRDatabase.database().reference()
    ref.child("Locations").observeSingleEventOfType(.Value, withBlock: { (snapshot) in
        let lat = (snapshot.value!["Latitude"] as! NSString).doubleValue
        let lon = (snapshot.value!["Longitude"] as! NSString).doubleValue



        let complainLoc = CLLocationCoordinate2DMake(lat, lon)

        let Coordinates = CLLocationCoordinate2D(latitude: lat, longitude: lon)

    })
Run Code Online (Sandbox Code Playgroud)

我的 JSON 树

我的代码块崩溃了

这是我用于将数据保存到 Firebase 的代码

FIRDatabase.database().reference().child("Location").child(FIRAuth.auth()!.currentUser!.uid).setValue(["Latitude": locationManager.location!.coordinate.latitude, "Longitude": locationManager.location!.coordinate.longitude])
Run Code Online (Sandbox Code Playgroud)

ios firebase swift firebase-realtime-database

4
推荐指数
2
解决办法
6683
查看次数

标签 统计

firebase ×1

firebase-realtime-database ×1

ios ×1

swift ×1