1
votes

I'm trying to connect a label from my prototype cell of the storyboard to my view controller. Every time I do this I get an error saying "Outlets cannot be connected to repeating content". I don't know why its doing that because I don't where I'm repeating the content but I've provide an image below. Just so you don't get confused the green comments that say "TOP cell: user post" the outlets are connected to the top of the view controller where you see user, message and time. I just want to create outlets from the prototype cell to the view controller without getting this error. I hope this was enough information.

enter image description here

2

2 Answers

2
votes

This label belong to UITableView cell. And you connect outlet to Controller so problem happen.

You should do this:

Create a table view cell subclass and set it as the class of the prototype. Add the outlets to that class and connect them.

0
votes

At run time, there might be zero instances of that cell, or one instance, or 100 instances, depending on how many rows your table view has. Each cell will have its own instance of that label. Which label do you think the outlet should be connected to? There is no good answer.

Anyway, when the view controller is loaded, there are definitely zero instances of the cell, so there is nothing to connect such an outlet to. The cell instances are created later, after the storyboard scene has been fully loaded, by tableView(_:cellForRowAtIndexPath:) calling dequeueReusableCellWithIdentifier(_:) repeatedly.