First, this is not a duplicate of What does this mean? "'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X"
I have looked at that question and a couple others, and have made sure that my class is connected through the identity inspector as well as the connections inspector. My class also shows up through the Automatic mode in the assistant editor.
if let currentUser = FIRAuth.auth()?.currentUser {
ref = FIRDatabase.database().reference()
ref.child("Teams").child(self.teamName.text!).setValue(["Name" : self.teamName.text!])
ref.child("Teams").child(self.teamName.text!).setValue(["Number" : self.teamNumber.text!])
ref.child("Teams").child(self.teamName.text!).setValue(["Password" : self.teamPassword.text!])
ref.child("Teams").child(self.teamName.text!).setValue(["memberCount" : 1])
print("1")
let userName = "member" + String(1)
let currentUserEmail = currentUser.uid
ref.child("Teams").child(self.teamName.text!).child("memberList").setValue([userName : currentUserEmail])
print("2")
if let userteamcount = self.ref.child("Users").child(currentUser.uid).value(forKey: "teamCount") as? Int {
let currentTeam = "team" + String(userteamcount + 1)
print("4")
self.ref.child("Users").child(currentUser.uid).setValue(["teamCount" : (userteamcount + 1)])
print("5")
self.ref.child("Users").child(currentUser.uid).child("joinedTeams").setValue([currentTeam : self.teamNumber.text!])
print("6")
}
}
An important note is that it prints out 1 and 2 before sending the error.
Also, here's the specfic error that I get:
1
2
Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<FIRDatabaseReference 0x618000054160> valueForUndefinedKey:]:
this class is not key value coding-compliant for the key teamCount.'
Thanks so much.