0

I want to read the data in the UIWebView response when it succeeded loading the url.

Catching this data in this method didn't give me the response:

- (void) webViewDidFinishLoad:(UIWebView *)_webView {

EDIT: I want to catch the NSURLResponse

Thanks, Nur

nurnachman
  • 4,468
  • 2
  • 37
  • 40
  • Are you sure you have declared the webview's delegate in .h file? – John Smith Jul 12 '12 at 15:03
  • 1
    @TeodorCarstea that doesn't make a difference. Obj-C is a dynamic language; message dispatch occurs at runtime, as long as you set the webview's delegate to `self`, regardless to the fact whether you have or haven't declared the protocol. –  Jul 12 '12 at 15:07

2 Answers2

0

Have you implemented –webView:didFailLoadWithError: ?

Probably an error when loading the URL.

some_id
  • 29,466
  • 62
  • 182
  • 304
0

I don't know enough about the architecture of your app to really say, but it might be useful for you to know that you can call arbitrary JavaScript on the page in your UIWebView from outside the UIWebView, and get the response back:

NSString *script = @"$('#textInputField').value";
NSString *result = [webView stringByEvaluatingJavaScriptFromString:script];

If you store the response in a JavaScript variable, you should be able to read it back up into your Obj-C this way.

Dan Ray
  • 21,623
  • 6
  • 63
  • 87