Reputation: 99
I have question concerning storyboards, namely I have used storyboard for long time and all was fine until now. I want to override - (id)instantiateViewControllerWithIdentifier:(NSString *)identifier method from storyboard class. I know that I must add subclass of UIStoryboard class, but I do not know how indicates the app that it should use this subclass? I know that I can do this programatically (allocate object instance of this subclass and get view controller) but I wonder - if it is possible to tell Xcode that my e.q. MainStoryboard.storyboard file class should be treat as my subclass.
Upvotes: 1
Views: 58
Reputation: 1305
Yes, you can. The best way is subclass UIStoryboard and create programatically instance of your storyboard in AppDelegate.
If you don't want to create storyboard in AppDelegate, you can use method swizzling - replace method implementations of UIStoryboard with your own (see objc/runtime.h header and apple docs ).
But I think that explicit storyboard creation is better than magical runtime - it's understandable for all who read your code.
Upvotes: 1