Swift - Assertion failed in - [UITableView _configureCellForDisplay: forIndexPath:]

I am getting an error after tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell

running multiple times.
Here's what: I created teacherArray

one that contains the data used for the cell and certainly contains what I need.
I used a storyboard to set up a cell and table. And I have verified that the id for the cell is set and I also configured the class for the tableview and the cell in the identity inspector.

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return teacherArray.count

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

    cell.nameLabel.text = teacherArray[indexPath.row].name
    cell.schoolLabel.text = teacherArray[indexPath.row].school
    cell.experienceLabel.text = teacherArray[indexPath.row].experience
    cell.courseLabel.text = teacherArray[indexPath.row].course


    return cell


I have tracked this method and it is after this console output:

PAL.SearchCell: 0x7bf32310; baseClass = UITableViewCell; frame = (0 450; 320 75); autoresize = W; layer = <CALayer: 0x7bf322e0>


... that I am getting this error message:

 2015-04-26 22:27:54.880 PAL[65213:6357947]*** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-3318.93/UITableView.m:7344
   *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'


I have no idea what I did wrong. Any idea?


source to share

1 answer

Try the following:

add UITableViewDataSource, UITableViewDelegate:
class HDMainHotBoleCtr: UIViewController, UITableViewDataSource, UITableViewDelegate {    




All Articles