在Swift中将String转换为CLLocationCoordinate2D

Lea*_*nin 12 string converter cllocation cllocationcoordinate2d swift

使用Firebase作为我的后端,我有一系列的经纬度坐标字符串,如何将它们转换为CLLocationCoordinate2D以便我可以使用它们进行注释?以下是每次更新时从Firebase获取信息的代码

var UpdateRef = Firebase(url:"https://ici.firebaseio.com/users")

UpdateRef.observeEventType(.ChildChanged, withBlock: { (snapshot) in
    let MomentaryLatitude = snapshot.value["latitude"] as? String
    let MomentaryLongitude = snapshot.value["longitude"] as? String
    let ID = snapshot.value["ID"] as? String

    println("\(MomentaryLatitude)")

    var Coordinates = CLLocationCoordinate2D(latitude: MomentaryLatitude as
        CLLocationDegrees, longitude: MomentaryLongitude as CLLocationDegrees)

}
Run Code Online (Sandbox Code Playgroud)

最后一行不起作用,我应该使用什么呢?

fre*_*138 20

使用该doubleValue属性:

let MomentaryLatitude = (snapshot.value["latitude"] as NSString).doubleValue
let MomentaryLongitude = (snapshot.value["longitude"] as NSString).doubleValue
Run Code Online (Sandbox Code Playgroud)