まず、これは私がその質問を見て、カップルの他の人と、私のクラスは、アイデンティティインスペクタと同様に接続インスペクタを介して接続されていることを確認してきているWhat does this mean? "'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X"このクラスは、キーXXXに対応するキー値をコード化していません - 正しくクラスされたクラスですか?
の複製ではありません。私のクラスは、アシスタントエディタの自動モードでも表示されます。
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")
}
}
重要な注意点は、エラーを送信する前に1と2が出力されることです。
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.'
本当にありがとうございました:
また、ここで私が手specficエラーです。
'子(currentUser.uid).VALUE(forKey: "teamCount")'がクラッシュしますが、この 'child'は' teamCount'特性を持っており、それはdoesnのことを想定しているので、 't。 – matt