views:

43

answers:

1

I know there are lots of other UIWebView local file related questions but I can't seem to find an answer to mine.

I'm downloading an HTML document and a CSS document and both get saved in the Documents directory. I need to be able to load images from the Resources directory and the CSS from the Documents directory.

So I've got different paths to deal with. Maybe there is a standard path to get to the Resources folder and then I can BaseURL to the Documents so I can get to the CSS?

Before anyone asks the reason is that I'm shipping lots of images bundled with the app but I know I will need to add additional one's as they become available and until I can get a new release out and approved I'd like to be able to reference images in the bundle and some externally (external website).

A: 

The app bundle is roughly [[NSBundle mainBundle] bundlePath].

The documents directory is roughly [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0].

If you mean you want relative URLs to work between them, the easiest way is probably to copy them to the same directory. I'm also pretty sure that you can embed a default Documents directory by sticking it alongside your .app in the zip; that way you can keep it all in Documents. (I haven't actually tested this though!)

tc.
Maybe I can modify the HTML using the paths I get from your suggested code before calling loadHTMLString. That way I could reference the Resources and Documents at the same time. Will have to try that out.
Will Rodgers