Reputation: 2573
I have a nib file created from Interface builder which I have inserted in a framework as bundle resources and added to my project. I am trying to load the nib file from the framework but not sure how to load it for a ViewController. Could anyone share any thoughts as of how to load the nib file from main bundle of the framework resource folder?
Thanks.
Upvotes: 0
Views: 2013
Reputation: 2573
Okay so after wondering around a bit, I finally got it working. Below is the content as of how I loaded nib file from external framework, might help someone in future.
NSString *resourceBundlePath = [[NSBundle mainBundle] pathForResource:@"TheFrameworkName" ofType:@"framework"];
NSLog(@"the bundle: %@",resourceBundlePath);
NSBundle* languageBundle = [NSBundle bundleWithPath:resourceBundlePath];
[languageBundle load];
NSLog(@"The bundle desc: %@",[languageBundle description]);
self.scanManual = [[Scanner alloc] initWithNibName:@"Resources/Scanner" bundle:languageBundle];
Since I was getting (null) contents in first few tries, its a good way of checking of the bundle is getting loaded by keeping NSLog. Thanks again to stackoverflow community
Upvotes: 1
Reputation: 2163
I am not sure that this will work for xib but This is how i am loading my images from bundle check if it is working for you.
But make sure that when you add your folder you should click on second radion button like image.
imageArray = (NSMutableArray *)[[NSBundle mainBundle] pathsForResourcesOfType:@"jpg" inDirectory:@"Beauty Shots_iPad"];
Upvotes: 0