Has anyone managed to create a custom UIStoryboard using Swift.
If you jump to the definition of UIStoryboard it only has one initialiser. However it seems to return a UIStoryboard.
init(name: String!, bundle storyboardBundleOrNil: NSBundle!) -> UIStoryboard
I though initialisers did not return a type. Anyway, when I attempt to call this super initialiser from my subclass initialiser I get the following error
Must call a designated initialiser of the superclass 'UIStoryboard'
Has anyone successfully done this. Is this a bug or am I doing it wrong?
Use the class (type) method to instantiate the storyboard.
let storyboard : UIStoryboard = UIStoryboard(name: "storyboardName", bundle: nil);
Edit:
You are not supposed to subclass UIStoryboard. There are no public designated initializers for this class. Instead you are supposed to use the class method to create your storyboard, as there is a lot of private Apple API code to load the storyboard from it's compiled *.storyboardc file. The actual loading of the storyboard must be done via the class method.
Subclassing wouldn't help since the class method is only guaranteed to return a UIStoryboard, and not your specific subclass. Try to use another design pattern to achieve your goals. You could add a category (Swift extension) to UIStoryboard to add whatever additional methods you want, and call those from your code.