简体   繁体   English

TableView CoreData错误:…在Swift中断言失败

[英]TableView CoreData error: Assertion failure in … in Swift

I implemented Core Data into my app. 我在我的应用程序中实现了核心数据。 If I run it, I get the following error: 2014-11-21 13:29:28.400 MyApp[2630:37096] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-3318.16.14/UITableView.m:6116 如果运行它,则会出现以下错误: 2014-11-21 13:29:28.400 MyApp[2630:37096] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-3318.16.14/UITableView.m:6116

I don't know what I've done wrong (I'm still learning swift). 我不知道自己做错了什么(我仍在学习敏捷)。

This is the function where the error occurred: 这是发生错误的函数:

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

    var cell:MyTableViewCell = tableViewNotes.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as MyTableViewCell
    cell.textLabel.text = "\(daten[indexPath.row].aufgabe)"

    return cell
}

and the line where the error occurred: 和发生错误的行:

var cell:MyTableViewCell = tableViewNotes.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as MyTableViewCell
used tabeView in place of tableViewNotes

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

    var cell:MyTableViewCell = tabeView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as MyTableViewCell
    cell.textLabel.text = "\(daten[indexPath.row].aufgabe)"

    return cell
}

Let me know if it works. 让我知道它是否有效。

Are you using your custom cell Identifier name "Cell" in your storyboard? 您是否在情节提要中使用自定义单元格标识符名称“ Cell”? If not. 如果不。 Please give this "Cell" to your custom cell Identifier . 请将此“单元格”提供给您的自定义单元格标识符。 And I hope it will work 我希望它能起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM