私は現在Firebaseデータベースからデータを取得してそれを独自の変数として設定しようとしていますが、各チャートの子は特定の日付と時刻です(yy.mm .dd.hms)。だから、私は必要なすべての日付を格納する配列を持っているが、私はスナップショットを呼び出すときにそれらを参照することはできません。私はエラーをスローするこれら2つの方法を試しました "(子:)空ではない文字列でなければならず、 '。' '#' '$' '[' または ']' '」配列を持つ子からFirebaseのスナップショットを受け取るSWIFT
var postCollection = [170802120618, 170802101427] //yy.mm.dd.hh.mm.ss
ref.child("users").child(uid!).child("Posts").child(self.postCollection[indexPath.row]).observe(.value, with: { (snapshot) in
for item in snapshot.children{
let snapshotValue = snapshot.value as? NSDictionary
let firstNameSnap = snapshotValue?["First Name"] as? String ?? ""
currentCell.nameLabel.text = firstNameSnap
}
})
と
var postCollection = [170802120618, 170802101427] //yy.mm.dd.hh.mm.ss
let selection = self.postCollection[indexPath.row]
ref.child("users").child(uid!).child("Posts").child(self.postCollection[indexPath).observe(.value, with: { (snapshot) in
for item in snapshot.children{
let snapshotValue = snapshot.value as? NSDictionary
let firstNameSnap = snapshotValue?["First Name"] as? String ?? ""
currentCell.nameLabel.text = firstNameSnap
}
})
とデータベース・チャートはおおよそであること:
FIR{
users{
uid{
username: UserName
Posts{
170802120618{
First Name: first
}
}
}
}
}
Iを取得します:何かは、以下の例になりますあなたが意味することを得るが、私はそれをどのように参照するのだろうか?私はcurrentUserまたはcurrentChildを使用することはできませんので、複数のユーザーに対してこれを実行しようとしています。 – itsTheJaguar