Reputation: 1805
NSURL *url =[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"index" ofType:@"html"inDirectory:@"www"]];
Giving me error of
[NSURL initFileURLWithPath:]: nil string parameter'
I had already copy folder 'www' to my project but giving me error and if i don't write inDirectory:@"www" then it will take the path but doesn't show the exactly page that i want to show.
Upvotes: 0
Views: 528
Reputation: 318804
When you add resources to your project, they all get copied to the root of your app bundle (by default). Any sort of yellow subfolders you may have setup in your project have no affect on how the resources get organized in the actual app.
The only way to end up with actual folders inside the app's final resource bundle is to have blue folders in your Xcode project.
Yellow folders are simply "groups".
Blue folders are "folder references". These are created when you choose to "Add Files to {Project Name}..." and select the "Create Folder References" option on the add file dialog (as opposed to the "Create Groups" option which results in yellow group folders).
Any blue folder references and their contents are put in your app's bundle in the same structure.
So for your case, you need to add the "www" folder as a folder reference instead of a normal group. Once this is done, your original code with the inDirectory:
parameter will work as desired.
If you have any issues you can always look inside the .app folder of the built app to verify if the desired directory structure has been created or not.
Upvotes: 1