I'm making an app that makes use of a framework that I'm creating.
The framework contains storyboards but in some cases the project making use of the framework will need to override the storyboard by providing a new one.
So my goal is to check if a storyboard with a given name exists in [NSBundle mainBundle]
, if not then I will get the base version from my framework.
I have tried getting the storyboard from the main bundle and checking for the result being nil but it throws an exception if it can't find it. So I then tried to catch the exception and then load the storyboard from the framework. This does work but it feels dirty and it could well hit the performance of my app.
I have also tried pathForResource
in the bundle:
if([[NSBundle mainBundle] pathForResource:name ofType:@"storyboard"] != nil) {
}
But this never finds the storyboard.
Does anyone know of any other way that I can check if a storyboard exists in a specific bundle?
So, I was nearly there with what I was already trying. As per a comment on my question, the compiled extension for a storyboard is "storyboardc". So I can check whether or not a storyboard exists in a bundle like so:
if([[NSBundle mainBundle] pathForResource:name ofType:@"storyboardc"] != nil) {
//The storyboard exists
} else {
//The storyboard isn't in the bundle, get it from the framework bundle.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With