1

Let me start by saying that this is not a question about setting the re-use identifier. The problem is that I'm getting the following error, despite having the re-use identifier set in the storyboard (and despite manually registering it using register(cellClass:forCellReuseIdentifier:)).

*** Terminating app due to uncaught exception 
'NSInternalInconsistencyException', reason: 
'unable to dequeue a cell with identifier TCAccountGroups - must register a 
nib or a class for the identifier or connect a prototype cell in a storyboard'

I am using both a Search Bar Controller and NSFetchedResultsController to make a searchable table that the user can select between existing options, or any user-defined option.

Any suggestions would be greatly appreciated. If I'm missing any useful information, I'll be more than happy to provide.

Edit: I forgot to mention that I'm using Swift 3.0.1, and XCode 8.0.1 on Mac OS Sierra 10.12.1.

Edit 2: The second-to-last message in XCode is:

*** Assertion failure in -[UISearchResultsTableView 
dequeueReusableCellWithIdentifier:forIndexPath:], 
/BuildRoot/Library/Caches/com.apple.xbs
/Sources/UIKit_Sim/UIKit-3600.5.2/UITableView.m:6593

So maybe there is a bug in the UISearchResultsTableView class?

Edit 3: Here are screenshots of my connections:

https://i.stack.imgur.com/7Y8TA.png

https://i.stack.imgur.com/M7IU2.png

https://i.stack.imgur.com/VAaeF.png

https://i.stack.imgur.com/EJLvp.png

My apologies for the links, but SO wouldn't let me save the images inline.

dohpaz42
  • 520
  • 4
  • 18

2 Answers2

1

I kept digging for a solution, and I stumbled onto what may be a workable solution. If anybody knows why using self.tableView works, when tableView doesn't, I'd love to know.

Community
  • 1
  • 1
dohpaz42
  • 520
  • 4
  • 18
  • Depends. You can check the tableView's connections inspector to see if it is connected to a default value in your UIViewController. If the tableview is inside of a UIViewController instead of within a UITableViewController then you may have to add the IBOutlet yourself. Or if using Swift 3, I think the use of self is now an explicit requirement in many cases. – Tommie C. Nov 06 '16 at 23:55
  • This is a `UITableViewController` with a `UISearchBarController` (Search Bar and Search Display Controller) added in the table header (using the Storyboard). The only outlet I set up was for the `UISearchBar`. – dohpaz42 Nov 06 '16 at 23:58
  • Add a couple of screenshots to the question which show the connections when you select the UI object having the issue. – Tommie C. Nov 07 '16 at 00:00
  • 1
    If you edit your question you can add the actual image to the question. This will make it easier for others trying to help to follow the updates you've provided. Just click the landscape icon next to the code icon. I can't see anything wrong with your setup. You might want to read the other answers at your referenced link since they seem to uncover some bugs. If you can replicate this try filing a bug report at http://bugreport.apple.com. They may fix it. – Tommie C. Nov 07 '16 at 00:23
0
  1. Open Main.StoryBoard
  2. Select the Cell of the table which is causing this error (TCAccountGroups in your case)
  3. Enter the identifier value i.e. "TCAccountGroups" under "Attribute Inspector" of Table View Cell.
  4. Build and Run the app - without exception this time.

Please see the image below:

Saima
  • 791
  • 1
  • 9
  • 13