iOS初心者メモ

Unsupported Configuration

  • 問題
    TableViewのCell設定に問題あり
warning: Unsupported Configuration: Prototype table cells must have reuse identifiers
  • 解決
    「Identifer」の項目に「Cell」を入力すると解消する

NSInternalInconsistencyException

  • 問題
'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier PostCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
  • 解決
    withIdentifier: “Cell”という指定が間違っていた
 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    guard let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as? PostCell else {
        fatalError("Invalid cell")
    }

    let post = posts[indexPath.row]
    cell.update(post: post)

    return cell
}