从“FIRRemoteConfigValue!”投射到不相关的类型“字符串”总是失败 [英] Cast from 'FIRRemoteConfigValue!' to unrelated type 'String' always fails

查看:142
本文介绍了从“FIRRemoteConfigValue!”投射到不相关的类型“字符串”总是失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



来自我的User类的示例

  init(snapshot:FIRDataSnapshot){
firstName = snapshot.value![firstName] as!字符串
lastName = snapshot.value![lastName] as!字符串
}

函数示例(我可以给出更多示例,基本上是相同的):
$ b

 func loadProfileImage(ref:FIRDatabaseReference){
ref.observeEventType (.Value,withBlock:{$ snapshot中
let base64String = snapshot.value![profileImgURL] as!String
let decodedData = NSData(base64EncodedString:base64String,options:NSDataBase64DecodingOptions.IgnoreUnknownCharacters)$ b $如果让decodeImage = 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窗格会导致此错误。只要我卸下吊舱,警告就消失了。肯定把这个作为一个错误。

I have about 50 of this same warning in my project. Since updating, all of my functions where I call snapshot.value["something"] as! String are failing. They all used to work before. I'm not even using the RemoteConfig feature. I just want to retrieve data.

Example from my User class:

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

Example from a function (I can give more examples but its basically more of the same):

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
            }
        })
    }

The app runs because they are just warnings but the warnings are correct because the app fails as soon as it tries to retrieve any data.

解决方案

So apparently having the Firebase/RemoteConfig pod causes this error. As soon as I uninstalled the pod, the warning went away. Definitely putting this in as a bug.

这篇关于从“FIRRemoteConfigValue!”投射到不相关的类型“字符串”总是失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆