현재 Firebase 데이터베이스에서 데이터를 가져 와서 자체 변수로 설정하려고 시도하고 있지만 각 차트의 자식은 특정 날짜와 시간 (yy.mm .dd.hms). 그래서 내가 필요한 모든 날짜를 저장하는 배열을 가지고 있지만 내 스냅 샷을 호출 할 때 참조 할 수 없습니다. 나는이 두 가지 방법을 시도했다. 오류 "(자식 :)은 비어 있지 않은 문자열이어야하고 '.' '#' '$' '['또는 ']' ''배열이있는 자식으로부터 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