ios - 候选人有不匹配的类型 UITableView?

标签 ios cocoa-touch uitableview swift

Xcode 说“Candidate 的 UITableView 类型不匹配......”有人知道如何解决这个问题吗?

func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) 
-> Int {
        return dataSource[section].count
       }

func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath!) 
-> UITableViewCell? {
        let cell = tableView!.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)                   as             UITableViewCell

        if let path = indexPath{
            let currentString = dataSource[path.section][path.row]
            cell.textLabel?.text = currentString
        }
        return cell
    }

最佳答案

函数签名已更改。您需要更新到这些:

func tableView(tableView: UITableView, numberOfRowsInSection section: Int)  -> Int {

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

关于ios - 候选人有不匹配的类型 UITableView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25801714/

相关文章:

ios - 获取 UIWebView 的 URL

iphone - 动画 UITableViewCell 高度和单元格 backgroundView

ios - 将电子邮件添加到 CNMutableContact 错误

iphone - 如何动态地将 UIImageView 添加到 View 并定位项目?

ios - UITableView 的 textLabel.text 位置在 iOS 中不居中

ios - 在 UITableViewController 中使用 UISearchDisplayController 时断言失败

ios - 仅在 didSelectRowAtIndexPath 中长按

ios - 用字符串中的空白字符替换 "0"

ios - 如何为以下内容正确使用 runAction 语法

ios - tableFooterView 中的 UIButton 未注册触摸