Reputation: 1521
I'm working on a storyBoard loading system and I need to check for the presence of a specific storyBoard.
I made a function checking for it (given a specific StoryBoard name) :
(NSString *)ressourceNameForDevice:(NSString *)rootName extension:(NSString *)ext
{
NSString *retString = rootName;
NSString *iPadString = [NSString stringWithFormat:@"%@-iPad", rootName];
NSString *iPhoneWideString = [NSString stringWithFormat:@"%@-wide", rootName];
if (IS_IPAD &&
(nil != [[NSBundle mainBundle] pathForResource:iPadString ofType:ext]))
{
retString = iPadString;
}
if (IS_IPHONE_WIDE &&
(nil != [[NSBundle mainBundle] pathForResource:iPhoneWideString ofType:ext]))
{
retString = iPhoneWideString;
}
return retString;
}
I'm calling this function with @"storyboard"
as extension argument.
My probleme is that the function fails on nil != [[NSBundle mainBundle] pathForResource:iPhoneWideString ofType:ext]
, even though the storyBoard IS present in my project and bundle, it doesn't get found. I guess I should give it another extension, I tried with @"nib"
too but no more result.
Anyone knows how to check that ?
Upvotes: 4
Views: 736
Reputation: 1521
Solved it. The problem was that once a storyBoard gets compiled the ressource extension isn't .storyboard
but .storyboardc
, same way that a .xib
compiled file has the .nib
extension.
Upvotes: 6
Reputation: 2088
Lets say you have "xyz.storyboard" in your project to be loaded. Then write it as:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"xyz"
bundle: nil];
It should do the needful.
Upvotes: -1