ios - 从 ITableViewCell 失望?到 UITableViewCell 只解包 optionals

标签 ios xcode swift tableview

我该如何解决这个问题?谢谢 这是一个 tableviewcell 错误,我不明白这个问题。请帮助我。 我有一个像 ITableViewCell 的 Downcast 这样的错误?到 UITableViewCell 只解包选项,你的意思是使用'!'?

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{

   var cell : UITableViewCell? = tableView.dequeueReusableCellWithIdentifier("cell") as?UITableViewCell

    if(cell == nil)
    {
        cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")
    }
    let film = self.filmler[indexPath.row] as! Dictionary<String, AnyObject>
    let filmAdi = film["ad"]! as! String
    cell!.textLabel!.text = filmAdi

    return cell!;
}

最佳答案

    var cell : UITableViewCell? = tableView.dequeueReusableCellWithIdentifier("cell")

    if cell == nil {
        cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")
    }

关于ios - 从 ITableViewCell 失望?到 UITableViewCell 只解包 optionals,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36350412/

相关文章:

swift - 如何让我的 Swift 单元测试访问 Parse 的 SDK?

ios - 使用 instantiateViewControllerWithIdentifier 但不使用 performSegueWithIdentifier 时出现延迟?

iphone - 使用 Plist 中的数据在 map 上显示多个 Pin 图

ios - 如何使用 CCUIViewWrapper 定位 View

ios - 标签栏下方的 Swift View 布局

ios - 以编程方式添加 UILabel 不可见

php - 内置 php 的推送通知提供程序

iphone - TapGestureRecognizer 不会被调用

iphone - Tab Bar Controller Inside Nav Controller,可以吗?

ios - 用户界面图像 :imageNamed on ipad fails ok in simulator