【发布时间】:2017-08-11 04:36:55
【问题描述】:
我很难在返回函数中使用 Firebase 值。这对我来说似乎是一个持续存在的问题。我已经写了一个关于我的问题的基本示例。我该怎么做呢?
func getChartIndexValues(completion:@escaping (Double) -> ()) {
//Firebase Initialization
var ref: FIRDatabaseReference!
ref = FIRDatabase.database().reference()
ref.child("general_room_index").observeSingleEvent(of: .value, with: {(snapshot) in
let snapDict = snapshot.value as? NSDictionary
var zero = snapDict?["0"] as! Double
completion(zero)
})
}
returnFunction() -> (Double) {
getChartIndexValues() { (zero) -> () in
let testValue = zero
}
return //THis is my problem
}
【问题讨论】:
标签: ios swift firebase swift3 firebase-realtime-database