Swift 3:从“UIView?"隐式强制的表达式去任何 [英] Swift 3: Expression implicitly coerced from 'UIView?' to Any

查看:24
本文介绍了Swift 3:从“UIView?"隐式强制的表达式去任何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其他人肯定在将 iOS 项目转换为 Swift 3 时(或之后)收到了此消息,但当我进行 Google 搜索时,却没有得到相关结果.

Someone else must have received this message while (or after) converting an iOS project to Swift 3, yet when I do a Google search, I get no relevant results.

无论如何,在转换为 Swift 3 后,我有大约 30 个警告说:

Anyway, after converting to Swift 3, I have about 30 warnings that say:

从 'UIView?' 隐式强制转换的表达式到任何

Expression implicitly coerced from 'UIView?' to Any

但是警告不指向任何特定的代码行.他们只引用存在警告的类.
有没有人了解这个警告或者我可以如何让他们保持沉默?

But the warnings do not point to any specific line of code. They only reference the class where the warning exists.
Does anyone have an insight into this warning or how I might go about silencing them?

推荐答案

就我而言,这是一个与没有明确类型的字典相关的问题:

In my case it was an issue related to a dictionary without explicit type:

let dict = ["key": value]

比我解决指定类型:

let dict: [String: Any] = ["key": value]

在您的情况下,您可以指定您的值类型:

In your case you can specify your value type:

let dict: [String: UIView] = ["key": value]

这篇关于Swift 3:从“UIView?"隐式强制的表达式去任何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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