Reputation: 963
On the face of it, this seems a very simple problem but for some reason I can't quite get it to work.
I have a magazine-style app that downloads the data for each issue in the form of a zipped bundle.
Once downloaded, and unpacked, the app successfully accesses the various files contained within the bundle as expected. These include JSON, PNG, JPG, video and so on.
However, I also included a XIB file that contains the physical layout of the content in a series of UIViews and it is this file that I cannot use.
The file is present but when I try and load it using:
UIViewController *controller = [[UIViewController alloc] initWithNibName: @"ViewController" bundle: assetBundle];
I get the following error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/C6718DB8-0C0F-4D38-84E6-55C145279957/Documents/asset-4.bundle> (not yet loaded)' with name 'ViewController''
Now, is this an iOS imposed limitation on not accessing XIBs from downloaded bundles, or some mistake I'm making in calling up the XIB for use?
I cannot find any explicit prohibition on using fetched bundles in this way however.
Upvotes: 3
Views: 2468
Reputation: 28688
I am unsure if you can 'legally' get away with this. But the problem is likely you are suppling a 'xib' instead of the compiled version the 'nib'.
You can do this manually from the command line by using the provided ibtool
program.
ibtool --errors --warnings --output-format human-readable-text --compile ${OUTPUT_NAME} ${INPUT_NAME}
You'd then place the compiled .nib file into the bundle and load as you've been trying.
Upvotes: 10