user1258240
user1258240

Reputation: 855

Create an outlet in storyboard to an inherited property

I'd like to create a basic view controller class BasicController with two subclasses SubclassController and AnotherSUbClassController. BasicController controls view that have a button inside them, so there should be a

weak var buttonThing: UIButton? 

property in it. In the actual implementation I want to use the subclasses in various parts of the interface: I want to draw them in storyboard, put buttons in that drawings, and connect the buttons to the inherited buttonThing property via an outlet. But wait, the buttonThing property was announced in the superclass and doesn't even appear in the code of the subclasses. So how do I connect the buttons to that outlet?

Upvotes: 2

Views: 1003

Answers (1)

vrwim
vrwim

Reputation: 14380

You can ctrl-drag the UIButton from your storyboard to your BasicController for each subclass you have laid out in your storyboard. You can then use the buttonThing in each subclass as usual.

Remember to link your subviewcontrollers to their respective viewcontrollers in the storyboard.

Upvotes: 4

Related Questions