swift - 使用 Swift 同步访问 Firebase Cloud Firestore

标签 swift google-cloud-firestore

好的,我刚刚开始研究 Firebase。所以说我想填充一个简单的表格 View 。看来我只能访问异步方法来访问其本地缓存?这是正确的吗?

所以这意味着我需要回调,然后填充我自己的内存缓存,然后 tableview 委托(delegate)方法可以访问它?那么现在我们实际上拥有相同数据的两个缓存?或者我在这里遗漏了什么?

最佳答案

Cloud Firestore 客户端会在应用的内存中保留您正在收听的所有数据的副本。删除某个位置的最后一个监听器后,数据将从内存中删除。

因为在 Firestore 中,offline persistence默认启用:

For Android and iOS, offline persistence is enabled by default. To disable persistence, set the PersistenceEnabled option to false.

客户端还将事件和最近的数据保存到磁盘。

并回答您的问题:

It seems that I only have access to async methods to access its local cache?

是的,没错。

So this means I need to callback and then populate my own in-memory cache that in turn the tableview delegate methods can then access?

你也是对的。

So now we effectively have two caches of the same data?

只要监听器处于事件状态,是的,您将拥有两个缓存。

关于swift - 使用 Swift 同步访问 Firebase Cloud Firestore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54949024/

相关文章:

android - 菲律宾的 Cloud Firestore 位置推荐

ios - 如何在主窗口和外部窗口的两个不相关 View Controller 之间传递引用(无segue,不同的SceneDelegate)

swift - SKNode() 仅限 360 度 zRotation

swift - 如何在 Swift 中使用计时器避免 "variable was written to, but never read"警告

flutter - 不安全的 Firestore 规则和应用程序检查 - 未经身份验证的数据库访问的正确方法?

ios - 如何从字典中检索 firestore 数据并填充 Tableview 行/部分?

firebase - 解析错误 : 'import' and 'export' may appear only with 'sourceType: module'

swift - 无法在强制转换中将类型 '<[AnyObject]>' 的值转换为类型 'NSArray'

ios - 汉堡菜单 UIPanGestureRecogniser

firebase - 如何在 Flutter 中从 Firebase Auth 获取用户 ID?