views:

37

answers:

1

Hi,

I'm trying to build a HTML based application for the iPad. I want to build a background process using Objective-C to download images and data and then refer to those from within a HTML file using the UIWebView.

I can successfully download an image and save it to the Documents sandbox directory. In the simulator I can see the path, but that's on my machine, not on the iPhone sandbox. Is there a shortcode for referencing the documents directory?

I want to do something like

~/Documents/image.png

Thanks

Robbie

A: 

To get the Documents directory I use

NSArray *documents = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
V1ru8
Yeah, I can get that, but I'd like to know if there's a way of getting to that file from a HTML img src attribute within the UIWebView. I don't think I can pass that into the UIWebView instance to use within the javascript code I'm using.
Robbie
Pass strings to javascript using stringByEvalutaingJavascriptFromString
drawnonward
Then I don't have any other solution then drawnonward.
V1ru8
OK, I'm getting somewhere using stringByEvalutaingJavascriptFromString. I can do something like an alert, but nothing seems to be happening when I'm calling a function that should be available. I'm waiting for the delegate webViewDidLoad callback before executing this. Can I call functions that should be in scope?
Robbie
Ah ok, it depends on the scope of the Javascript. Had to get a function defined as:function myFunc(){...} instead of myFunc = function(){...}All working,thanks
Robbie