开发者

How to filter out duplicate requests in UIWebView

开发者 https://www.devze.com 2023-04-10 06:52 出处:网络
I am writing an iPhone app that integrates with Foursquare via OAuth.I am able to log in, obtain an access token, and use the API endpoints.I do the log in with a UIWebView.

I am writing an iPhone app that integrates with Foursquare via OAuth. I am able to log in, obtain an access token, and use the API endpoints. I do the log in with a UIWebView.

The problem is that for every tap on the web view (Login, Allow, etc.), two identical requests are made. So when I dismiss the web view after obtaining an access token, the web view's didFailLoadWith开发者_StackOverflow社区Error: message fires, presumably for the second (duplicate) request. This is causing crashes and unwanted behavior.

Is there any way I can prevent the duplicate requests from happening or can I 'filter' them out?


fa solution for filtering out: You can set the delegate-property of UIWebView to nil before dismissing it.

self.myWebView.delegate = nil;
self.myWebView = nil; //retain-property

edit: but this will not really prevent the UIWebView to send the second request over the wire. This will only end up with not being notified twice. You have to discover why the second request is sent.

0

精彩评论

暂无评论...
验证码 换一张
取 消