1
votes

I have a generic view controller in my Storyboard, let's say it's class set to MyController class. I also have a view controller class (MySubControllerA) which inherits from MyController:

@interface MySubControllerA <MyController>
...
@end

The descendant class is used to overwrite some functions in the parent class.

I can instantiate the main class with this:

[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"MyController"];

But of course this will be instantiated in the class which is given in the Storyboard for the "MyController" identifier.

I want to have an instance of MySubControllerA which accesses everything which was set in the Storyboard and still has it's own functions. Is this possible somehow? Maybe it is not the proper way to solve this problem. Is there a better way to do this? I really don't want to mess MyController with the specific code which I belongs to MySubControllerA.

1
The storyboard is going to instantiate whatever class your controller is set to, so you should set the controller in the storyboard to be a MySubControllerA. It will still inherit what it needs from MyController.rdelmar
I want to instantiate the same Storyboard object as multiple subclasses.gklka
Well, what you want, and what is possible are two different things.rdelmar

1 Answers

2
votes

This is a very common feature request for storyboards, but unfortunately isn't possible at this point. I can tell you from weeks of first hand experience that if you try and hack a way to make this work, you will regret it.