【发布时间】:2015-10-23 02:08:33
【问题描述】:
我有以下代码。我正在使用所有可能的 Xcode 建议以及关于 SO 等的各种来源,但我似乎无法纠正可选问题:
var cell =
tableview!.dequeueReusableCellWithIdentifier(identifier as String) as? UITableViewCell?
if (cell == nil)
{
cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier:identifier as String)
cell.backgroundColor = UIColor.clearColor()
// ERROR HERE
}
cell.textLabel?.text = dataArray.objectAtIndex(indexPath.row).valueForKey("category_name") as! String
// ERROR HERE
var str = String(format: "%@%@%@",kServerURl,"/upload/",dataArray.objectAtIndex(indexPath.row).valueForKey("category_image") as! String)
cell?.imageView?.image = UIImage(data: NSData(contentsOfURL: NSURL(string:str)!)!)
// ERROR HERE
return cell
//ERROR HERE
错误:
可选类型 UITABLEVIEWCELL 的价值未展开您是否打算使用!还是?
不管我用!或者 ?我得到同样的错误,在某些情况下,如果两个错误会解决!被添加层单元格!!。
【问题讨论】: