我想在函数中更改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 ?? ""