dimanche 26 avril 2015

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


Getting the error after tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell runs for the several time.
Here's thing.I've create a teacherArray that contains the data used for the cell.And it surely contains what I need.I used the storyboard to custom the cell and the tableview.And I've checked that the identifier for cell is set and I also customize the class for the tableview and the cell in the identity inspector.

Code:

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

    println(indexPath.row)
    println(cell)

    return cell
}

I've track the method, and it's after the console output the following information that the error happened

6 PAL.SearchCell: 0x7bf32310; baseClass = UITableViewCell; frame = (0 450; 320 75); autoresize = W; layer =

and the following is 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 2015-04-26 22:27:54.889 PAL[65213:6357947] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'

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


Aucun commentaire:

Enregistrer un commentaire