gpt4 book ai didi

swift - 此类不符合键名的键值编码

转载 作者:行者123 更新时间:2023-11-28 07:41:18 24 4
gpt4 key购买 nike

<分区>

当我将值传递给采用键值字典的方法时,我遇到了一个问题:

func fetchUserAndSetupNavBarTitle() {
guard let uid = Auth.auth().currentUser?.uid else {
return
}
Database.database().reference().child("users").child(uid).observeSingleEvent(of: .value, with: {
(snapshot) in
if let dictionary = snapshot.value as? [String: AnyObject] {
// self.navigationItem.title = dictionary["name"] as? String

let user = User1()
user.setValuesForKeys(dictionary)
self.setupNavBarWithUser(user: user)
}
}, withCancel: nil)
}

我收到这个错误:

terminating with uncaught exception of type NSException
this class is not key value coding-compliant for the key name

错误发生在这一行:user.setValuesForKeys(dictionary)

这个问题不是另一个问题的副本,因为每个问题都是由不同的问题引起的

作为对评论的回应,User1 类包含:

class User1: NSObject {
var name: String?
var email: String?
var profileImageUrl: String?
}

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