Ios 候选人是否具有不匹配的UITableView类型?
Xcode说“候选者具有不匹配的UITableView类型…”有人知道如何解决这个问题吗Ios 候选人是否具有不匹配的UITableView类型?,ios,cocoa-touch,uitableview,swift,Ios,Cocoa Touch,Uitableview,Swift,Xcode说“候选者具有不匹配的UITableView类型…”有人知道如何解决这个问题吗 func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -> Int { return dataSource[section].count } func tableView(tableView: UITableView?, cellForRowAtIndexPath ind
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 {
及
欢迎使用Stackoverflow。对该场景稍作解释可能有助于专家理解该问题。谢谢!第一个现在可以工作了,但是在我删除“!”之后,“if let path=indexPath”上会出现一个错误,并说“条件绑定中的绑定值必须是可选类型”。我该怎么办?因为indexPath不再是可选的,所以不需要
if
条件。试着把它去掉。现在效果很好。谢谢。
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {