1 Replies - 3682 Views - Last Post: 07 October 2012 - 06:50 PM

#1 justin78  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 07-October 12

how address path works in xcode

Posted 07 October 2012 - 03:59 PM

I want to load html5 page, in my UIWebView in xcode, when I added files in my project for example: "for my html5:

I have css folder I have javascript file I have images, and my folder structure is like:

css/
javascript/
images/


when I adde these folders in xcode and I run the program, xcode can n't get the address, it can load the html page but with out any picture, javascript and css since they are in the other folders, I know, when I put all file together not in separate folder everything works but I want to have real folder structure in my xcode (I don't want to use group) would you please help me


for example

here it's works

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"about.html" ofType:nil]]; 


but when I add about in one folder like

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"test/about.html" ofType:nil]];


the link it dosent work, How can I fixed this path problem in xcode


when I run about.html if all css,javascript and images are located in about folder everything works in xcode

but when I have them in separate folder about can not load the css / javascript and images

would you please give me some hints

Thanks in advance!



  NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"page1.html" ofType:nil]];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];



I want to use something like this folder : test/

  [NSBundle mainBundle]pathForResource:@"test/page1.html" ofType:nil]];


Is This A Good Question/Topic? 1
  • +

Replies To: how address path works in xcode

#2 Elnaz Shahmehr  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 07-October 12

Re: how address path works in xcode

Posted 07 October 2012 - 06:50 PM

Use it like this:


    NSURL *url = [NSURL fileURLWithPath:[ [ NSBundle mainBundle ] pathForResource: @"test/page1" ofType:@"html" ]];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1