not good but great

プログラミング、アート、映画・本の感想について書きます。

unable to dequeue a cell with identifier reuseIdentifierが出たときの対処法

これが出て困っていた

'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier reuseIdentifier - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

「Identifier」に"Cell"

こちらにある通り、やってみる。
いつか見た惑星: iOSでテーブルビューを使う
「Identifier」に"Cell"と入力しても駄目だった。

"reuseIdentifier"の書き換えを忘れていた

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

    // Configure the cell...
    let post:Post = posts[indexPath.row]
    cell.textLabel?.text = post.postTitle

    return cell
}

reuseIdentifierになっていたのが原因。

let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell

Cellに変えればOK。