1

I am currently using firebase and I need to update a global variable declared in another swift class, the only was I now is to use an inout parameter. However, the firebase snapshot gives me a data snapshot that is not explicit and I get an error. Attached below is the error I get. Any help would be awesome!

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

    })
}

And I get an error that says "escaping closures can only capture input parameters explicitly by value"

KENdi
  • 7,576
  • 2
  • 16
  • 31
  • 1
    Possible duplicate of [Swift 3.0 Error: Escaping closures can only capture inout parameters explicitly by value](https://stackoverflow.com/questions/39569114/swift-3-0-error-escaping-closures-can-only-capture-inout-parameters-explicitly) – kevin Aug 04 '17 at 00:36
  • [This solution](https://stackoverflow.com/a/51619714/2880627) show how to modify a pass-by-reference variable in an escaping closure. – ukim Jul 31 '18 at 18:27

0 Answers0