ios - 从 'FIRRemoteConfigValue!' 转换为无关类型 'String' 总是失败

标签 ios swift firebase firebase-realtime-database

我的项目中有大约 50 个相同的警告。自更新以来,我将 snapshot.value["something"] 称为我的所有函数!字符串 失败。他们都曾经工作过。我什至没有使用 RemoteConfig 功能。我只是想检索数据。

来 self 的用户类的示例:

init(snapshot: FIRDataSnapshot) {
        firstName = snapshot.value!["firstName"] as! String
        lastName = snapshot.value!["lastName"] as! String
}

一个函数的例子(我可以给出更多的例子,但它基本上是一样的):

func loadProfileImage(ref:FIRDatabaseReference) {
        ref.observeEventType(.Value, withBlock: {snapshot in
            let base64String = snapshot.value!["profileImgURL"] as! String
            let decodedData = NSData(base64EncodedString: base64String, options:NSDataBase64DecodingOptions.IgnoreUnknownCharacters)
            if let decodedImage = UIImage(data: decodedData!) {
                self.profileImgImageView.contentMode = .ScaleAspectFill
                self.profileImgImageView.layer.cornerRadius = self.profileImgImageView.frame.size.width / 2
                self.profileImgImageView.clipsToBounds = true
                self.profileImgImageView.image = decodedImage as UIImage
            }
        })
    }

应用程序运行是因为它们只是警告,但警告是正确的,因为应用程序在尝试检索任何数据后立即失败。

最佳答案

显然,使用 Firebase/RemoteConfig pod 会导致此错误。一旦我卸载了 pod,警告就消失了。绝对把它作为一个错误。

关于ios - 从 'FIRRemoteConfigValue!' 转换为无关类型 'String' 总是失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37335486/

相关文章:

android - 谷歌服务 json 缺少 client_type 3

android - 如何防止 Android 版 Firebase 数据库中的重复数据

iOS 本地推送通知覆盖静音/静默模式

ios - apns - 如何提示用户仅在相关时启用推送通知?

swift - UITabBarItems 在子类化 UITabBarController 后不显示

objective-c - Swift NSData 初始化器

iOS Swift Firebase - 如何使当前用户数据在整个应用程序中可用?

ios - SpriteKit中的加速度计不起作用

ios - 在 iOS 上通过 Facebook 页面的图形 API 进行排序

swift - 停止从不同的 View Controller 更新位置