Swift 3.0中的UIView?()构造函数发生了什么?
在Swift 2.2中,我经常使用类似于let x = UIView?()的简洁语法来声明variables。 这给了x UIView? 键入,并用nil初始化它。  (当然,在这些例子中,你可以使用任何types而不是UIView ) 
 但是,当我在Swift 3.0中做同样的事情时,我得到一个错误: Cannot invoke initializer for type 'UIView?' with no arguments  Cannot invoke initializer for type 'UIView?' with no arguments 。 它还说, Overloads for 'UIView?' exist with these partially matching parameter lists: (Wrapped), (nilLiteral: ())  Overloads for 'UIView?' exist with these partially matching parameter lists: (Wrapped), (nilLiteral: ()) 。 不知何故,我不认为UIView?(nilLiteral: ())是我所追求的。 
 当然,还有其他的方法可以做同样的事情,比如let x: UIView? = nil  let x: UIView? = nil , let x = nil as UIView() ,但它们比我以前使用的方法更详细。 在Swift 3.0中移除了UIView?()构造函数UIView?()还是以我尚未发现的formsreplace它? 
下面将x初始化为零,括号是完全多余的。
 var x: UIView? return x == nil 
将返回true
查看开发人员文档以获取更多信息。
如果您定义了一个可选variables而不提供默认值,则该variables会自动设置为零:
 var surveyAnswer: String? // surveyAnswer is automatically set to nil 
@Hamish发表评论,澄清为什么UIView?()不再起作用:
“语法UIView? 只是可选的语法糖,因此UIView?()只是Optional.init()的语法糖。 在Swift 2中,可选的init()构造一个新的可选值,设置为.None。 所以是的,它工作正常。 然而,在Swift 3中,这个初始化器已经被删除了,这就是为什么UIView?()不再起作用的原因了“