简体   繁体   English

删除 Swift 结构中的旧获取项

[英]Delete old fetching items in Swift struct

I have a struct model in my Swift projects that read data from firestore database.我的 Swift 项目中有一个结构 model 从 Firestore 数据库读取数据。 I have inserted a bad item and now my app crash every time, even if i delete this item from the firestore console.我插入了一个坏项目,现在我的应用程序每次都会崩溃,即使我从 Firestore 控制台中删除了这个项目。 The error in my log console is Fatal error: Unable to initialize type Ordine with dictionary.我的日志控制台中的错误是致命错误:无法使用字典初始化类型 Ordine。 And it is always the same bad item.它总是同一个坏项目。 How can i delete old fetching data from my project?如何从我的项目中删除旧的获取数据?

This is my code in my viewcontroller:这是我的视图控制器中的代码:

override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.listener =  query?.addSnapshotListener { (documents, error) in
            guard let snapshot = documents else {
                print("Error fetching documents results: \(error!)")
                return
            }

            let results = snapshot.documents.map { (document) -> Ordine in
                if let ordine = Ordine(dictionary: document.data(), id: document.documentID) {
                    return ordine
                } else {
                    fatalError("Unable to initialize type \(Ordine.self) with dictionary \(document.data())")
                }
            }

            self.ordini = results
            self.documents = snapshot.documents
            self.TableView.reloadData()

        }
    }

I believe Firestore stores locally as well, so it's possible it is still trying to find something that is either not there or still faulty.我相信 Firestore 也会在本地存储,因此它可能仍在尝试查找不存在或仍然存在故障的东西。 I would try deleting the build from your device/sim (this will clear out your bad data) and re-run.我会尝试从您的设备/sim 中删除构建(这将清除您的不良数据)并重新运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM