Firebase runTransactionBlock

I read the firebase.google example here https://firebase.google.com/docs/database/ios/save-data#save_data_as_transactions and I'm trying to write my own version. I'm having problems because the firebase example leaves me more confused than I was before I started

All I try to do is when a person presses a button, this is that it is ++ (or + = 1) to the account and another button deletes it

Can someone help me figure out how to do this ... another user on the previous question posted links to other language answers, and I tried to write it in fast speech, but I failed

+6
source share
1 answer

Thanks to the comments above, I was able to get this to work

....runTransactionBlock { (currentData: FIRMutableData) -> FIRTransactionResult in var value = currentData.value as? Int if value == nil { value = 0 } currentData.value = value! + 1 return FIRTransactionResult.successWithValue(currentData) } 
+9
source

All Articles