【问题标题】:Xcode 6.1 Error bound value in a conditional binding must be Optional typeXcode 6.1 条件绑定中的错误绑定值必须是可选类型
【发布时间】:2015-01-29 20:28:05
【问题描述】:

我当前的 swift 代码

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 {

提前致谢。

【问题讨论】:

  • 也一直在尝试解决这个问题。

标签: ios xcode swift


【解决方案1】:

cell.textLabel 在每次发布 Xcode 时都会不断更改其可选状态,这非常令人恼火。检查它在您使用的版本中是如何定义的,您可能不需要可选绑定。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-29
    • 1970-01-01
    • 1970-01-01
    • 2015-09-11
    相关资源
    最近更新 更多