1

I am trying to load messages from Firebase but its telling me "Ambiguous use of observe"

Please help...new to IOS

 func fetchMessages(){
    let messageDB = Database.database().reference().child("Messages")


    messageDB.observe(.childAdded) { (snapshot) in
        let snapshotValue = snapshot.value as! Dictionary<String,String>
        let message = Message()
        message.messageBody = snapshotValue["MessageBody"]!
        message.sender = snapshotValue["Sender"]!
        self.messageArray.append(message)
        self.configureTableView()
        self.messageTableView.reloadData()
KENdi
  • 7,576
  • 2
  • 16
  • 31
Banotik
  • 21
  • 1
  • 2
  • Check out this question https://stackoverflow.com/questions/40057276/ambiguous-use-of-observe-firebase-db. Seems that the issue is `.observe.(childAdded)` should be `.observe(.childAdded, with: { snapshot` – Jen Person Feb 09 '18 at 00:01
  • This worked! Thank you @JenPerson – Banotik Feb 13 '18 at 20:21

0 Answers0