gklka
gklka

Reputation: 2574

Instantiate view controller from Storyboard with a descendant class

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.

Upvotes: 1

Views: 550

Answers (1)

InkGolem
InkGolem

Reputation: 2762

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.

Upvotes: 2

Related Questions