Ambiguous Use of Observe Firebase Db

Ambiguous use of observe firebase DB

Change this:

ref.child("Settings").child("service_types").observe(.value) { (snapshot) in

}

to this:

ref.child("Settings").child("service_types").observe(.value, with: { snapshot in

})

See also firebase documentation section Listen for value events

Ambiguous use of 'observeSingleEvent(of: with:)

Working solution for Swift 3:

databaseRef.child("Users").queryOrderedByKey().observe(.childAdded, with: { snapshot in

})

Firebase 3: Ambiguous use of 'observeEventType(_:withBlock:)'

It seems like it's a Swift bug, try to use this syntax instead (without trailing closure syntax.):

ref.observeEventType(.Value, withBlock: { firDataSnapshot in

})

More info: Ambiguous use of 'observeSingleEventOfType(_:withBlock:)' error in Swift

Ambiguous use of 'subscript(_:)' after Pod Install

Why subscript snapshot.value every time it's used?

let ref = Database.database().reference()
ref.child("Postbox").observe(.childAdded, with: { (snapshot) in
let data = snapshot.value as? NSDictionary
let monToFri = data!["Monday to Friday Collection Time"] as? String ?? "Empty String"

// Other code....
}

Ambiguous use of 'subscript' and Cannot call value of non-function type 'AnyObject' errors retrieving data from Firebase in SWIFT 4.1

You changed [] to ()

let dic = snapshot.value as! [String:String]
let date = dic["Date"]
let time = dic["Time"]
let latitude = dic["Latitude"]
let longitude = dic["Longitude"]
let desc = dic["Description"]


Related Topics



Leave a reply



Submit