如何从Firebase请求中获取响应? 因此,例如,一旦我有子计数值,就启动一个函数。
let FAref = Firebase(url: "https://my-app.firebaseio.com/Users/\(uid!)/Data")
FAref.observeEventType(FEventType.Value, withBlock: { (snapshot) -> Void in
if snapshot != nil {
self.count = Int(snapshot.childrenCount)
}
}) { (error) -> Void in
print(error.description)
}
答案 0 :(得分:0)
let FAref = Firebase(url: "https://my-app.firebaseio.com/Users/\(uid!)/Data")
FAref.observeEventType(FEventType.Value, withBlock: { (snapshot) -> Void in
if snapshot != nil {
let count = Int(snapshot.childrenCount)
//Just add the function call after you get the childrenCount
self.myFunction(count)
}
}) { (error) -> Void in
print(error.description)
}