简体   繁体   中英

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

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? If not. Please give this "Cell" to your custom cell Identifier . And I hope it will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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