Strange error when adding items to prototype cells in storyboard-IB

Alex Godbehere picture Alex Godbehere · Aug 28, 2012 · Viewed 24.9k times · Source

I have quite a large project (~20 scenes). One of which is a TableViewController with a custom UITableViewController class. I have given the cell a reuse identifier, and added a label to it. When I try and Ctrl+Drag the label to the UITableViewController header file to create an outlet, I get the following error:

error: Illegal Configuration: Connection "tableInfoView" cannot have a prototype object as its destination.

What is this? Am I overlooking something obvious? Or do I need to create a custom cell class and drag the outlet to that? If so, how do I then specify the data which is displayed uniquely for each cell from the UITableViewController?

Answer

dulgan picture dulgan · Oct 25, 2012

In fact you can't just make an outlet from a dynamic cell prototype in the UITableView delegate view controller.

You'll have to subclass UITableViewCell and then attribute this class to your prototype.

Then you can Ctrl-Drag from the Label to the UITableViewCell subclass header file.

Finaly you can access to this outlet in the delegate code after having imported the UITableViewCell header file in it.

This is documented by Apple there at "The Technique for Dynamic Row Content" section.