I face a problem when I pass values to method that take a key value dictionary:
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)
}
I get this error:
terminating with uncaught exception of type NSException
this class is not key value coding-compliant for the key name
The error occur at this line: user.setValuesForKeys(dictionary)
This question is not a copy to another questions since each question is caused by a different problem
In response to a comment, the User1 class contains:
class User1: NSObject {
var name: String?
var email: String?
var profileImageUrl: String?
}