简体   繁体   中英

Unable to dequeue a cell with identifier “GroupMessageCell”

I have two tableViews displayed within a tab. For the first one that opens, there is no error, but upon selecting the second tab, the error appears:

2016-05-17 21:07:23.730 FeastApp[11007:172938] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UITableView.m:6573
2016-05-17 21:07:23.736 FeastApp[11007:172938] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier GroupMessageCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'

Even though I have set the row identifier as: GroupMessageCell :

在此输入图像描述

within my nested TableView:

在此输入图像描述

and class:

class GroupMessageList: UITableViewController {

    var getGroups: Firebase!
    var groups: [Group] = []

    override func viewDidLoad() {
        super.viewDidLoad()

        getGroupsWithMessages()

    }

    override func viewWillAppear(animated: Bool) {

        super.viewWillAppear(animated)
    }

    // MARK: - Table View

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        return self.groups.count
    }

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

        group = groups[indexPath.row]

        // Update the rows with the proper object
        cell.textLabel!.text = "\(group.groupName) \(group.groupID)"
        return cell
    }

    func getGroupsWithMessages() {

        getGroups = Firebase(url: Global.sharedInstance.firebaseMainURL + "usersGroups/" + Global.sharedInstance.userID)

        self.getGroups.observeSingleEventOfType(.Value, withBlock: { snapshot in

            print(snapshot)

            for detailData in snapshot.children {

               // print(detailData.value)

               self.groups.append(Group(groupName: "test", groupID: detailData.key))

                print(self.groups.count)

            }

            self.tableView!.reloadData()

        })
    }        
}

How can I prevent this error from occurring?

You have not set the class for GroupMessageCell

to do select storyboard and

在此输入图像描述

and then

在此输入图像描述

verify that Class GroupMessageCell

set identifier

在此输入图像描述

Three Potentials Trouble Areas:

  1. Ensure the cell identifier is present - [Looks fine based on your details]

  2. Did you set the class of your TableViewController to GroupMessageList on the storyboard like so: 自定义表视图类

  3. Does the error still occur after you run Product > Clean.

Hope one of these helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM