Problem connecting a Label from a new class that isn't ViewController class

Help me please!
I am working in a personal project in Siwft 5, Xcode 12.4. I have two class in the project: ViewController and BlackBoardStack.
In the storyBoard have a Label, i want to control that from BlackBoard class. That label is inside of the a stackView, the stackView is hooked up to viewCcontroller through @IBOutlet.
In the identity inspector, i set the custom class of the stackView like BlackBoardStack class.
When i want to connect the label to the Blackboard class through @IBOutlet, i can’t do that! Don’t appear the option

What i am doing wrong ?
What sub class of BlackBoard class i should set for connect the label?

Thanks to all!

I’m confused what this means.

You can do the same was as you did for the BlackBoardStack class you do for the BlackBoard class. Make sure BlackBoard class conforms to UILabel

1 Like

@Martinn ,

Can you post a screenshot of your storyboard showing the ViewControllers (if you have more than one) and the objects that you have added into them.

1 Like

Hi mikaela! excuse me, i wrote the question wrong.
I have two class (ViewController and BlackBoardStack) i want to connect a label to the BlackBoardStack class.
I connected the stackView to ViewController. Inside of stackView there is a Label, and i want to connect that label to BlackBoardClass.

I should make a sub class (UILabel) in BlackboardStack class?

Thanks for you time!

Hi Chris, yes !
It’s ok like that?
tell me please,

Thank for your time !

What is the BlackBoardStack? Can you paste that code here too?

What do you mean:

It looked like you’ve just dropped it in the storyboard? What’s “connected mean?”

Please post it as text, not a screenshot. You can do this by placing three backticks on the line before your code and three backticks on the line after your code so that it will be formatted properly. You can also highlight an entire code block and click the </> button on the toolbar to wrap the block for you.

This makes it far easier to read and also makes it easier for other posters to copy/paste the code in order to test solutions and such.

BlackBoardStack is a Class.
I connect the satackView through @IBoutlet to the ViewController Class.
I want to connect the Label (from storyBoard) through @IBOutlet to the BlackBoardStack Class, but i can’t.
How can i do it ?

This is ViewController Class


    @IBOutlet weak var stackView: UIStackView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }
} ```

This is BlackBoardClass 
eee```  class BlackBoardStack: UIStackView {

} ```

Thanks

It might be easier to explain what you are trying to achieve with your project. At the moment I can see that in your storyboard you have a Label inside a StackView. What do you want to do with the Label?

i want to connect the label (through @IBOutlet) to the BlackBoardStack class.
Because i want to control the color and the text of the label, from BlackboardStack class, not from the ViewController.

Thanks

In UIKit the elements you add into a storyboard that is of class ViewController need to be controlled within that ViewController class. If you have a label inside a StackView then the IBOutlet for that label needs to be connected to the same ViewController class in which the stackView object is added.

Can you explain why you have an IBOutlet connected to your stackView?

A StackView is simply a container. It’s purpose is to group a number of UI elements inside it and arrange them in a manner that requires fewer constraints than would be the case if you applied individual constraints to each of the UI elements.

1 Like

Thanks for your explanation, is very clear.
Thanks for your help !