I'm reading firebase.google's example seen here https://firebase.google.com/docs/database/ios/save-data#save_data_as_transactions and I am trying to write my own version. I am having trouble as the firebase example leaves me more confused than i was before i started
All i am trying to do is when a person taps a button is that it ++ (or +=1) to the count and another button removes it
Can somebody help me figure out how to do this...another user on a previous question posted links to other language answers and i tried to write it in the swift language but I failed miserably
Thanks to the comments seen 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)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With