I am trying to include a folder structure into my xcode project that contains html, css, js and images like below:
htmlcontent
html
test.html
css
test.css
js
test.js
I copied the folder and its subfolder to xcode and i can see the heirachy there but when i do the following:
NSString *pathToFile = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:pathToFile isDirectory:NO];
[_webView loadRequest:[NSURLRequest requestWithURL:url]];
it prints:
/Users/scoota/Library/Application Support/iPhone Simulator/6.0/Applications/8AAC5870-DF24-49BB-BCB8-598C8C0A7C9A/TestApp.app/test.html
Is there a way to preserve the hierachy? The reason i ask is my html file has references to the css like so:
<link rel="stylesheet" type="text/css" href="htmlcontent/test.css" media="screen, projector" />
As a result the css is not loaded. If I change it to the following:
<link rel="stylesheet" type="text/css" href="test.css" media="screen, projector" />
it loads.
Any thoughts?
When you add files to your Xcode project, make sure you select "make folder references" instead of "make groups for folders"
However, shouldn't that be ,,/css/test.css ?