Cannot convert value of type 'DataEventType.Type' to expected argument type 'DataEventType'

Please help,


My app has recently broken since my cocoapods has updated FireBase


I am getting the error: Cannot convert value of type 'DataEventType.Type' to expected argument type 'DataEventType'


on line 3


func fetchVenue(){
        dbRef.observe(DataEventType, with: { (snapshot:DataSnapshot) in
            var newPlaces = [Venue]()
          
          
            for venue in snapshot.children.allObjects{
                let venueObject = Venue(snapshot: venue as! FIRDataSnapshot)
                newPlaces.append(venueObject)
            }
          
            self.places = newPlaces
            self.tableView.reloadData()
        })
   }


Please help

Is "dbRef" a FireBase object? In that case you should check the documentation for the "observe" function. Based on the error message, it sounds like the first parameter should be a value (or reference) of type DataEventType, but you're passing the type itself.

Try passing an instance of DataEventType not the actual Class itself.


h ttps://firebase.google.com/docs/reference/ios/firebasedatabase/api/reference/Classes/FIRDatabaseQuery

Hi and thanks, I changed

dbRef.observe(DataEventType, with: { (snapshot:DataSnapshot) in

for this:

dbRef.observe(_ eventType: DataEventType, with block: @escaping (DataSnapshot) -> Void) -> UInt


now I am getting even more errors


here is my function:

func fetchVenue(){
      
        dbRef.observe(_ eventType: DataEventType, with block: @escaping (DataSnapshot) -> Void) -> UInt
        /
            var newPlaces = [Venue]()
          
          
            for venue in snapshot.children.allObjects{
                let venueObject = Venue(snapshot: venue as! FIRDataSnapshot)
                newPlaces.append(venueObject)
            }
          
            self.places = newPlaces
            self.tableView.reloadData()
        })
   }


and dbRef is

var dbRef:DatabaseReference!


Please help

It's norma, you're calling erroneously.l.


observe(_ eventType: DataEventType, with block: @escaping (DataSnapshot) -> Void) -> UInt

// returns : A handle used to unregister this block later using removeObserverWithHandle

is the func signature. You do not call with this form.


To call it, you need to pass arguments, such as:

let anEventType : DataEventType = // Give it an approrpiate value


then call

    let returnHandle = dbRef.observe(anEventType) {  (DataSnapshot) -> Void in … }          //  here the trailing closure
Cannot convert value of type 'DataEventType.Type' to expected argument type 'DataEventType'
 
 
Q