When I try to increase currentNumberAdmin
I get:
cannot convert value of type \'UILabel!\' to expected argument \'type in out String\'
<
This is crashing because of this line: currentNumberAdmin += String(1)
. You're attempting to add a String value to a UILabel value, which is invalid. You're literally telling the compiler to assign currentNumberAdmin
, a UILabel, to the value of the expression of adding a UILabel to a String, which the compiler doesn't know how to do, hence the exception message.
It's not entirely clear why you're attempt to set the label's text twice: once with snapshot.value, and then again on the next line. If what you're trying to do is set the label's text to the snapshot value + 1, do something like this:
@IBAction func nextCurrent(_ sender: UIButton) {
let database = FIRDatabase.database().reference()
database.child("current").observe(FIRDataEventType.value, with: { (snapshot) in
var strVal = Int(self.currentNumberAdmin.text)!
strVal += 1
self.currentNumberAdmin.text = String(strVal)
})
}