Search Results

Search found 3 results on 1 pages for 'thomax'.

Page 1/1 | 1 

  • iPhone dev: load a file from resource folder

    - by thomax
    I'm writing an iPhone app with a UIWebView which should display various html files I have in the app resource folder. In xcode my project overview, these html files are displayed like this: dirA |---> index.html |---> a1.html |---> a2.html |---> my.css |---> dirB |---> b1.html |---> b2.html |---> dirC |---> c1.html |---> c2.html These resources where added to the project as such: - Checked "Copy items into destination groups folder (if needed)". - Reference type: Default. - Text encoding: Unicode (utf-8). - Recursively create groups for any added folders. The links in my html are relative, meaning they look like this: <a href="a1.html">a2</a> <a href="a2.html">a2</a> <a href="dirB/b2.html">b2</a> <a href="dirC/c1.html">b2</a> In order to display the index.html when the app starts up, I use the following code: NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; NSURL *url = [NSURL fileURLWithPath:path]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request]; This works fine. Following links from the index file also works fine, as long as the html files requested are directly under dirA. If the link followed points to a file in a sub-directory, then didFailLoadWithError will catch the situation and report that the requested file does not exist. Note that [webView loadHtmlString:myHtml]; cannot be part of the solution, as I need back and forward buttons to work in my web view. So the question is: How can I follow a relative link to an html file in a sub directory within my resources? I've been all over stackoverflow and the rest of the tubes for the past few days trying to figure this one out, but nowhere have I come across the solution to this exact problem. Any insight at all would be very, very much appreciated!

    Read the article

  • iPhone dev: Recurse all project resoureces and collect paths

    - by thomax
    I have a bunch of HTML resources in my app organized in a hierarchy like so: dirA |---> index.html |---> a1.html |---> a2.html |---> dirB |---> b1.html |---> b2.html |---> dirC |---> c5.html |---> c19.html I'm trying to collect the absolute paths of all HTML resources however deep down, but can't seem to figure out how. So far I've tried: NSArray myPaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"html" inDirectory:nil]; This returns an empty array, because I have no HTML files at the root of my project. Then there is: NSArray myPaths = [[NSBundle mainBundle] pathsForResourcesOfType:@"html" inDirectory:@"dirA"]; This returns an array containing only the paths for the three HTML resources directly below dirA. If I read the doc correctly, I guess this is to be expected; pathsForResourcesOfType does not traverse subdirectories. But is there a (preferably nice) way to do it?

    Read the article

1