OGeek|极客世界-中国程序员成长平台

标题: iOS - 如何禁用 Firebase 缓存? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 12:45
标题: iOS - 如何禁用 Firebase 缓存?

我删除了 firebase 节点中的 post 对象。

但是当我查询帖子对象时,会显示以前缓存的帖子对象。

我没有从 firebase 获取刷新数据。

问题: 有没有办法停止 firebase 缓存并从 iOS 中的 firebase 获取刷新的数据?

我的代码:

self.firPostRef.child(userID).observeSingleEvent(of: .value, with: { (snapshot) in
        if snapshot.value is NSNull { completion(nil) }
        else {
            //print(snapshot.debugDescription)
            let postids = Array((snapshot.value as! [String:AnyObject]).keys)

            print(postids)
            completion(postids)

        }
    }) { (error) in
        debugPrint("error occured in getting all comments -" + error.localizedDescription)
    }



Best Answer-推荐答案


使用 observeSingleEventOfType,reference.keepSynced(true)。一旦执行此代码,它就会刷新数据。

使用 observeEventOfType。这将始终保持您的数据同步,并在您进行更改后立即再次执行。

关于iOS - 如何禁用 Firebase 缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41695419/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4