更改外部函数的变量值

时间:2018-12-21 14:00:46

标签: swift function variables

我想在函数中更改sPu的值,并在其外部的值中使用新值。

var sPu:String?

ref2.observeSingleEvent(of: .value, with: { (snapshot) in
    guard let dictionary = snapshot.value as? [String: AnyObject]  else {
        return
    }
    let user = User(dictionary: dictionary)
    sPu = user.pu
}, withCancel: nil)

values["sentPublic"] = sPu ?? ""

0 个答案:

没有答案