CoderWang CoderWang - 1 year ago 94
iOS Question

Crashing: storyboardWithName:

Using the following method to get storyboard instance:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"storyboardName" bundle:nil];

I have noted that "If no storyboard resource file matching name exists, an exception is thrown with description: Could not find a storyboard named 'XXXXXX' in bundle....". I know it cannot be too careful to deal with the method.

My question is that is there any way to catch the exception and handle it manually.
Any directions?

Tom Tom
Answer Source
NSString *sbName = @"storyboardName";
UIStoryboard *sb;
@try {
     sb = [UIStoryboard storyboardWithName:sbName bundle:nil];
}@catch (NSException *exception) {
     [self warnMissingStoryBoard:sbName];
     //handle here...
//use sb here...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download