【发布时间】:2016-09-04 05:11:11
【问题描述】:
我目前正在使用 firebase 来检索用户信息。一旦我收到数据,我想在所有闭包之外使用数据,我创建了一个完成块,问题是我无法将完成变量添加到结果中,因为结果在另一个闭包内。如何解决这个问题。提前感谢您的帮助。
func userInfo(userId:String,completion:(result:String)->Void){
fireBaseAPI().childRef("version_one/frontEnd/users/\(fireBaseAPI().currentUserId()!)/email").observeEventType(.Value, withBlock: {snapshot in
let email = snapshot.value as! String
//this is incorrect because it is inside a firebase closure how can I make it work I know i have it outside the closure but i will not be able to retrieve the info from firebase
result = email
})
}
【问题讨论】:
-
更清楚你想要什么,并提供更多关于
fireBaseAPI()的信息