Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read JSON content from UIWebView

I'm using a UIWebView to display a captcha. If the user enters the captcha correctly, then the server returns data using JSON serialization. I don't want the view to display this, instead I want to intercept the loads of the UIWebView, and if it returns JSON serialized data, I want to store that data and remove the UIWebView.

I was thinking of setting up a delegate to the UIWebView and use its webViewDidFinishLoad, but how do I get the content loaded?

like image 773
quano Avatar asked Dec 03 '25 00:12

quano


1 Answers

You may want to look into defining a UIWebViewDelegate and using webView:shouldStartLoadWithRequest:navigationType: to intercept the request and handle it.

In your case, you would evaluate the NSURLRequest and return NO to prevent the WebView from loading. In turn, you would create a separate NSURLConnection with the same request, and set up a delegate to receive the (JSON) response.

like image 148
David Carney Avatar answered Dec 05 '25 14:12

David Carney



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!