【发布时间】:2020-03-02 08:44:26
【问题描述】:
我要做的就是将我的 Firestore 数据下载到我的 tableview 上
func loaddailymotivation() {
FirebaseReferece(.MotivationDAILY).getDocuments { (snapshot, error) in
if let error = error {
print("error getting MOTIVATIONDAILY DATA \(error.localizedDescription)")
}
else {
guard let snapshot = snapshot else { return }
for allDocument in snapshot.documents {
let data = allDocument.data()
print("\(allDocument.documentID) => \(allDocument.data())")
print("we have\(snapshot.documents.count) documents in this array")
let dailymotivationTitle = data["Motivation title"] as? String
let dailyMotivationScripture = data["motivation scripture"] as? String
let newthought = RealMotivatioNDataModel(Realmotivation: dailymotivationTitle!, RealmotivationScrip: dailyMotivationScripture!)
//self.motivationArray.append(newthought)
}
self.tableview.reloadData()
}
}
}
不太清楚为什么我的应用程序总是崩溃说致命错误:在展开可选值时意外发现 nil:文件我要上传屏幕截图以获取更多信息
import Foundation
import UIKit
class RealMotivatioNDataModel {
var RealmotivationTitle : String!
var realmotivationDailyScripture : String!
init(Realmotivation : String, RealmotivationScrip : String) {
self.realmotivationDailyScripture = Realmotivation
self.RealmotivationTitle = RealmotivationScrip
}
}
【问题讨论】:
-
您在哪一行得到异常?
-
调试并尝试找出您的
dailyMotivationTitle或dailyMotivationStripture为空的原因。
标签: ios swift firebase google-cloud-firestore