Possible Duplicate:
Can you reference Xib files from static libraries on the iPhone?
I have created an iOS framework and it includes a xib view. When I debugged the program, this line of code worked fine:
MyViewController *controller = [[MyViewController alloc] initWithNibName:@"MyView" bundle:[NSBundle mainBundle]];
However, when I 'reference' the framework from another project - the nib is no longer in the 'mainBundle'. What should I do with the code above (that is part of the framework) so it loads from the framework and not the consuming application project?
The framework in question should have a bundle identifier in its Info.plist
file typically. In the application that makes use of this custom framework, you should be able to access resources in this bundle by:
NSString *frameworkBundleID = @"com.yourCompany.YourFrameworkBundleID";
NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:frameworkBundleID];
This is the NSBundle
from which you can access framework resources.
EDIT:
There appears to be an alternate (possibly better) means of accessing the bundle in question.
e.g.:
NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@"MyLibraryResources" withExtension:@"bundle"]];
See this excellent tutorial
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