i'm trying to put NIB/XIB files in a bundle I call Configuration.bundle. When I try to load the xib from my bundle the app crashes because it can't find the xib file.
NSBundle *bundle = [NSBundle bundleWithPath:[[NSBundle mainBundle]
pathForResource:@"Configuration" ofType:@"bundle"]];
[bundle load];
NSLog(@"bundle: %@", bundle);
I get the output
bundle: NSBundle (not yet loaded)
The 'not yet loaded' part scares me a bit. Why isn't it loaded?
And finally when I try to load my nib with the view controller
ConfigViewController *configViewController = [[ConfigViewController alloc] initWithNibName:@"ConfigViewController" bundle:bundle];
I get the output
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (not yet loaded)' with name 'ConfigViewController.xib'
I've tried both with and without .xib.
Any ideas?
Best Answer
The load method is used to load executable code like frameworks and these things.
Your bundle doesn't contain any executable file that you want to load, so you don't neel to call [bundle load].
If the name of the bundle ir right, then all you've written except for [bundle load] is fine.Anyways check that the path is the right ones, don't nest too much the instructions:
If this string is the right path, then you are sure that the bundle will be loaded correctly without calling [bundle load].