2014-11-21 7 views
0

내 응용 프로그램에 핵심 데이터를 구현했습니다. 실행하면 다음과 같은 오류가 발생합니다. 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:6116TableView CoreData 오류 : Swift의 어설 션 오류

내가 뭘 잘못했는지 (아직도 배우고 있어요) 모르겠어요.

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 
} 

및 오류가 발생한 행 :

var cell:MyTableViewCell = tableViewNotes.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as MyTableViewCell 

답변

0
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 
} 

가 작동하는지 알려줘

이 오류가 발생한 기능입니다.

+0

빠른 답변 감사합니다! 이제 CoreData 라이브러리에 중단 점이 생깁니다. 그러나 그것은 효과가있는 것으로 보인다. 나는 한 발 더 나아 갔다. – hom

0

스토리 보드에 맞춤 셀 식별자 이름 "셀"을 사용하고 있습니까? 그렇지 않은 경우. 이 "셀"을 사용자 지정 셀 식별자에 지정하십시오. 그리고 그것이 효과가 있기를 바랍니다.

+0

답장을 보내 주셔서 감사합니다. 나는 스토리 보드를 사용하지 않는다. 프로그래밍 방식으로이 작업을 수행하려면 어떻게해야합니까? – hom

+0

그런 다음 식별자가 "Cell"인 MyTableViewCell의 xib 하위 클래스에서 셀을 가져와야합니다. 메소드가 dequeueReusableCellWithIdentifier (식별자 : 문자열, forIndexPath indexPath : NSIndexPath) -> AnyObject // 새로운 dequeue 메소드를 사용하면 식별자가 등록되었다고 가정하면 셀이 반환되고 올바르게 크기가 조절됩니다. 그렇지 않으면 var cell : MyTableViewCell! = tableView.dequeueReusableCellWithIdentifier ("셀") ​​MyTableViewCell로? if cell == nil { cell = UITableViewCell (스타일 : .Default, reuseIdentifier : "Cell") } –