独学でSwift勉強中です。
今日は”App Development with Swift”の4.5 Table Viewを実践していました。
出てきたエラーは、以下の通り。
Exception: “unable to dequeue a cell with identifier Emojicell – must register a nib or a class for the identifier or connect a prototype cell in a storyboard”

調べてみると、これはStoryboardにあるTable view controllerのidentifierと、codeで指定されているidentifierが一致していないことが原因みたいです。
まず、StoryboardのTable cellを選択し、identifierの名前を確認してください。(デフォルトだとCellらしいです。)

次に、Table viewに紐付けされてるSwiftファイルを開き、
let cell = tableView.dequeueReusableCell(withIdentifier: “identifierの名前”, for: indexPath)と記載されている場所を探してください。このidentifierの名前と、Storyboard上で指定されているidentifierの名前が一致していないか確認してください。私の場合、StoryboardではEmojiCellとなっていたのに、コード上ではEmojicellとなっていました。

これを修正すればうまくデバックできました!
参考:
https://www.hackingwithswift.com/example-code/uikit/fixing-unable-to-dequeue-a-cell-with-identifier
コメント