dequeueReusableCellWithIdentifier keeps returning nil

I’m basically trying to do what’s in this link

How to Implement Custom Table View Section Headers and Footers with Storyboard

  • How to suppress warnings in Xcode?
  • Unable to use pod in Notification service extension
  • Converting a Swift UnsafePointer<AudioStreamBasicDescription> to a Dictionary?
  • iOS: How to copy HTML into the cut-paste buffer?
  • How to turn an NSArray of strings into an array of unique strings, in the same order?
  • Presenting a specific view controller from AppDelegate
  • In my storyboard, I’ve embedded static cells in my TableViewController

    I selected one of my table view cells and set the identifier as “CustomHeader” (at the storyboard)

    and below is a snippet of my code

    override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
            var headerView:UITableViewCell? = tableView.dequeueReusableCellWithIdentifier("CustomHeader") as? UITableViewCell
            if (headerView == nil){
            return headerView
        override func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
            return 30

    However, console keeps printing “errrrrrr” meaning that headerView is nil.

    But I think whose identifier is “CustomHeader” cannot be nil because I manually selected a cell and set its identifier as CustomHeader in the storyboard!!

    I’m new to iOS so I don’t get what the problem is.

    Any help is appreciated.

    Thanks in advance!

    Solutions Collect From Internet About “dequeueReusableCellWithIdentifier keeps returning nil”

    To dequeue a cell from a storyboard, you need to use the method which takes an index path. That is, don’t use:


    Instead, use:


    The hacky approach in the question you linked to no longer works. This method returns a header. Don’t dequeue a cell.

    You should use registerNib(_:forHeaderFooterViewReuseIdentifier:) or registerClass(_:forHeaderFooterViewReuseIdentifier:), and dequeueReusableHeaderFooterViewWithIdentifier(_:), as documented.