tags:

views:

1314

answers:

5

I have an application that I am working on that uses UIWebView. I'm not much of a Web Wonk so I am not familiar with what is probably a trivial task- How do I pass data back to my application when I load a web site? The site is on a server that passes a google map to the application but I also need some additional information passed along with it. I would think this is simple. Where do I start to accomplish this?

+1  A: 

You probably don't want to use a UIWebView. Instead look at NSURLRequest to download the HTML source for a page.

Ben Alpert
Is the purpose of NSURLRequest to allow variables to be passed to a web application?
A: 

Well, what sort of information is it?

If it is text, you could suck the text down in XML or some other mechanism, and then dynamically build your HTML page, then pass that to the UIWebView.

If it is image data, you could do the same with data: urls, it's a little tricky but it can be done.

If you just need to load the web page into the webview, there is a method for that in the UIWebView initializers.

Genericrich
I am looking to send a couple of points along with the google map. Just text- no images
A: 

The information is a couple of coordinates that I want passed with the google map.

JMeringer
A: 

Just do:

document.location = something you'll recognise containign the coords.

And then handle

webView:shouldStartLoadWithRequest:navigationType:

in UIWebViewDelegate, do whatever you want and return NO. You can also use a url scheme which your app recognises, but I haven't explored that approach yet.

Airsource Ltd
A: 

What kind of object is Document? Do I declare this? I'm getting up to speed with Cocoa, the Iphone SDK & Object oriented programming so if you could provide just a little more detail it would really be appreciated. If I am following you this far - I am asking the server for a web page, at the load request I will extract the information I need from the page load, and then discard it before I load it. Is this true? Thanks -JM