I keep getting an error message. I've looked through similar questions on google, and they talk about something having to do the storyboard and outlets. Whenever I set my title directly with self.navigation.title = ___
, i don't get an issue. It's only when I used using setValuesForKeys(dictionary)
exception 'NSUnknownKeyException', reason: '[<FirebaseApp.User 0x600001558940> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key email.'
I have a NSObject with the following. The values are written exactly how I have them on firebase.
class User: NSObject {
var email: String!
var photoURL: String!
var username: String!
class MessageController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
var ref: DatabaseReference!
ref = Database.database().reference()
let userID = Auth.auth().currentUser?.uid
ref.child("users/profile").child(userID!).observeSingleEvent(of: .value, with: { (snapshot) in
print(snapshot)
if let dictionary = snapshot.value as? [String: AnyObject] {
// self.navigationItem.title = dictionary["username"] as? String
let user = User()
user.setValuesForKeys(dictionary)
self.setUpNavBar(user: user)
}
}, withCancel: nil)
}
func setUpNavBar(user: User) {
self.navigationItem.title = user.username
}