【发布时间】:2017-02-05 12:09:38
【问题描述】:
我有一个酒店预订应用程序,它向用户显示可滑动的日历。现在的最终目标是提供一个类似于日历的界面,在每个保留的日期下方都有小点。现在,我只是想在控制台上打印开始日期和结束日期之间的所有预订(其中开始日期和结束日期分别是月份的开始和结束)。
但是,我无法让它与 Firebase 一起使用。以下是目前 Firebase 上的数据:
{
"reservations" : {
"-KSgRjwpssoZJWjV9ScM" : {
"checkin" : 1474950600,
"checkout" : 1475116200,
"customer" : "-KMVMMudWJlFeiimtgJl"
}
}
}
这是我检索数据的 Swift 代码:
private var ref: FIRDatabaseReference!
// viewdidload:
ref = FIRDatabase.database().reference()
ref.keepSynced(true)
// logic to fetch data
DispatchQueue.global().async {
// Background Processing
// Check Firebase for events between startdate and enddate
print("Fetching Reservations")
print(startDate.timeIntervalSince1970)
print(endDate.timeIntervalSince1970)
self.ref.child("reservations").queryStarting(atValue: startDate.timeIntervalSince1970, childKey: "checkin").observe(.childAdded, with: { (snapshot) -> Void in
print("Data Retrieved.\n")
print(snapshot)
})
}
这是现在打印到控制台上的内容:
Fetching Reservations
1469989800.0
1472581800.0
Fetching Reservations
1472668200.0
1475173800.0
由于数据在第二个范围内清晰可见,但我仍然无法显示。
这里可能有什么问题?谢谢。
【问题讨论】:
标签: ios swift firebase firebase-realtime-database swift3