:私がしようとするとはchildByAutoId()の後ろに値に到達するためにどのように
Projects:
|
-------KyHzk8VtHitcLlYw1MT
|
- ProjectName: "ProjectNameTest"
|
- Creator: "CreatorTest"
- And so on...
:
let ref = Database.database().reference(fromURL: "https://projectsupport-e475b.firebaseio.com/").child("Projects").childByAutoId()
let values = ["ProjectTitle": ProjectTitle, "Fighters": EarlySupporters, "Tags": Tags, "TotalFighters": "0", "Description": Description, "ProfileImage": profileImageUrl, "Creator": self.username!] as [String : Any]
ref.updateChildValues(values)
は、これは私のデータベースです
Database.database().reference().child("Projects").observe(.childAdded, with: { (snapshot) in
if let dictionary = snapshot.value as? [String : AnyObject]
{
let project = Project(dictionary: dictionary)
//The following line was the problem:
//project.setValuesForKeys(dictionary)
//I'm still not sure why that solved the problem.
print(project)
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
print(snapshot)
}, withCancel: nil)
これは、次のようになりクラッシュ:私は、次のコードを使用してデータを取得するを0
キャッチされていない例外「NSUnknownKeyException」が原因でアプリを終了しています。理由は「[setValue:forUndefinedKey:]:このクラスはキークリエイターのキー値に符合していません。
データへのアクセス方法を教えてください。どのようにして鍵を入手できますか?
まず、あなたの値が正しく更新されているかどうかチェックしましたか?あなたの辞書を印刷して、スナップショット値を正しく取得するかどうか確認できますか? – Arrabidas92
あなたの問題はあなたのデータがファイアベースではないと思います。 – TheeBen
私はそれについてはわかりません。 –