斯威夫特3:表达暗示强迫来自'UIView?'去任何 [英] Swift 3: Expression implicitly coerced from 'UIView?' to Any

查看:224
本文介绍了斯威夫特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?'强制转换为Any

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]

这篇关于斯威夫特3:表达暗示强迫来自'UIView?'去任何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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