的Xcode 6.1中的错误条件的结合的约束值必须是可选类型

问题描述:

我当前SWIFT代码的Xcode 6.1中的错误条件的结合的约束值必须是可选类型

override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) { 
cell.backgroundColor = UIColor.blackColor() 

if let textLabel = cell.textLabel { 
    textLabel.textColor = UIColor.whiteColor() 
    textLabel.highlightedTextColor = textLabel.textColor 
} 

越来越错误:“绑定的值在条件结合必须是可选的类型为”在3行:

if let textLabel = cell.textLabel { 

在此先感谢。

+0

一直试图弄清楚这一点。 – Unheilig 2014-12-01 19:44:56

cell.textLabel不断更改其可选状态与每个版本的Xcode,这是非常刺激。查看它在您使用的版本中的定义,您可能不需要可选的绑定。