I have this piece of code in my program that should allow a user to tap on a message and the score should increase by one:
super.collectionView(collectionVie
You have set up an observer that should observe any value changes in the "messages"-tree and all of its children nodes.
This means that whenever you update the score, you'll also receive information on this in your observer - and your code will run again. To fix this so your score only will be set once you have to change your observer to only fetch changes once:
rootRef.child("messages").observeSingleEventOfType(.Value, withBlock:
Read more here: https://firebase.google.com/docs/database/ios/retrieve-data
I would also recommend you to take a look at the structure your database-section: https://firebase.google.com/docs/database/ios/structure-data