简体   繁体   English

从“UIButton”到“UIButton”的条件转换总是成功

[英]Conditional cast from 'UIButton' to 'UIButton' always succeeds

i'm a newer on IOS , when i download other workspaces into my xcodes, it give some warnings on the project,anyone helps ?我是 IOS 的新手,当我将其他工作区下载到我的 xcode 中时,它会在项目上发出一些警告,有人帮忙吗? thanks!!!谢谢!!! so don't decrease my score, anyone has been a time newer?所以不要降低我的分数,有人更新了吗? this is the code这是代码

let button = UIButton(type: UIButtonType.System) as?让 button = UIButton(type: UIButtonType.System) as? UIButton用户界面按钮

You don't need the cast.你不需要演员。 Swift can easily deduce type in this case.在这种情况下,Swift 可以很容易地推断出类型。 This is enough:这就够了:

let button = UIButton(type: .System)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM