1
votes

This code is now displaying data in the app as Optional('data') since updating to Swift 3.0. Any idea?

let ring1FightRef = FIRDatabase.database().reference().child("Ring1Fighting")


@IBOutlet weak var ring1Fighting: UILabel!

Here is the code in viewDidLoad

ring1FightRef.observe(.value) { (snap: FIRDataSnapshot) in self.ring1Fighting.text = (snap.value as AnyObject).description
    }
2

2 Answers

2
votes

You just need to unwrap the value that you recieve:-

FIRDatabase.database().reference().child("Ring1Fighting").observe(.value) { (snap: FIRDataSnapshot) in

        print((snap.value as! String))


    }
1
votes

I hade the same issue before and here is what was my solution Just make it simple and change it to the following

self.labelName.text = snap.value as? String