0
我有以下錯誤:從拋型的功能轉換無效 '(_)拋出 - >()' 非拋函數型 '(DataSnapshot) - >虛空'
Invalid conversion from throwing function of type '(_) throws ->()' to non-throwing function type '(DataSnapshot) -> Void'
func getUserList() throws {
var ref: DatabaseReference!
ref = Database.database().reference()
ref.child("User").observeSingleEvent(of: .value, with: { (snapshot) in
let value = snapshot.value as? NSDictionary
let keys = value?.allKeys
for key in keys! {
let dict = value?[key] as? NSDictionary
let user = User.init(name: dict?["Name"] as? String ?? "", selected: dict?["Selected"] as? String ?? "")
let viewUser = ViewUser.init(user: user)
self.data.append(viewUser)
debugPrint(user ?? "")
}
self.tableView.reloadData()
if value?.count == 0 {
throw UserError.Empty
}
})
}