如何使用不使用显式值的inout参数更新其范围之外的变量

时间:2017-08-04 00:31:03

标签: swift firebase swift3

我目前正在使用firebase,我需要更新在另一个swift类中声明的全局变量,我现在唯一要使用的是inout参数。但是,firebase快照为我提供了一个不明确的数据快照,并且出现错误。以下是我得到的错误。任何帮助都会很棒!

func changeYourVariable( theString: inout String , indexPaths : Int) {
    self.DatabaseHandle = ref.child("Frontpage").child(String(indexPaths)).observe(.value, with: { (TheCategory) in
        theString = TheCategory.childSnapshot(forPath: "Category").value as! String

    })
}

我得到一个错误,上面写着“转义闭包只能通过值显式捕获输入参数”

0 个答案:

没有答案