所以目前我正在試圖從我的火力地堡的數據庫中提取數據,並將其設爲自己的變量,但每個圖表的孩子是一個特定的日期和時間(yy.mm .dd.hms)。所以我有一個數組存儲我需要的所有日期,但叫我的快照時,我不能引用它們。我已經試過這兩種方法哪個拋出錯誤「(孩子:)必須是一個非空字符串,不能包含‘’ '#' '$' '[' 或 ']''」接聽火力地堡快照從一個孩子的數組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
}
}
}
}
}
我明白你的意思,但是我會如何引用它?我試圖爲一個以上的用戶這樣做,所以我不能使用currentUser或currentChild。 – itsTheJaguar