Search code examples
iosswiftinheritanceuistoryboardibaction

Can't link a bar button to an @IBAction in superclass


I have a number of view controllers, each with their own menu button (a UIBarButton, added in the storyboard). Now I want to link all these up to a single @IBAction function in their superclass (the superclass is the same for all the view controllers with that menubutton).

Now I have linked up @IBOutlets to a superclass before, but it doesn't seem to work with @IBActions, even though the function isn't private, and it definitely is part of the superclass (I am refactoring, previously it was an @IBAction in each class, which only did menuButtonTap() (calling the method in the superclass).

Any ideas?


Solution

  • I have solved the problem by manually creating an @IBAction on the superclass, and giving them the same name as the ones I create in the subclasses. Then I deleted the ones in the subclasses. This leaves a 'dangling reference' from the storyboard, according to Xcode, but I know it's there.