gpt4 book ai didi

Swift 无法将类型的值转换为预期的参数类型

转载 作者:行者123 更新时间:2023-11-30 13:02:25 24 4
gpt4 key购买 nike

override func viewDidLoad() {
super.viewDidLoad()
let ref = FIRDatabase.database().reference()
ref.observe(.value, with: {
snapshot in
self.label1.text = (snapshot.value as AnyObject)["label"] as! String
}, withCancel: {
error in
print(error.description)
})
// Do any additional setup after loading the view, typically from a nib.
}

Line }, withCancel: { 显示编译器错误:

cannot convert value of type '(_) -> ()' to expected argument type '((Error) -> Void)'

最佳答案

试试这个

override func viewDidLoad() {
super.viewDidLoad()
let ref = FIRDatabase.database().reference()
ref.observe(.value, with: {
snapshot in
self.label1.text = (snapshot.value as AnyObject)["label"] as! String
}, withCancel: {
(error:Error) -> Void in
print(error.description)
})
// Do any additional setup after loading the view, typically from a nib.
}

关于Swift 无法将类型的值转换为预期的参数类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39767575/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com