0

I have a weird issue. Here is the setup:

  • I have a NSOperationQueue which I add NSOperation subclass objects to. These do networking using NSURLConnection sendSynchronousRequest method. As I understand it, these are completely asynchronous, since they are NSOperations which each get their own thread.
  • If I launch my app WITHOUT any background networking operations, loading a URL into a UIWebView works just fine.
  • If I launch my app, and run some background networking operations, loading a URL into a UIWebView results in this error:

    Error Domain=WebKitErrorDomain Code=102 UserInfo=0x1996d60 "Frame load interrupted"

and any subesequent attempts to load a UIWebView fails with the same error.

Is there some weird interaction between UIWebView and NSURLConnection that I need to be aware of? My next step is to replace the synchronous calls with a fully async NSOperation, but it is such a weird bug that I figured I would ask the experts.

I have isolated the error down to the NSURLConnection sendSynchronousRequest method. If I call this from an NSOperation, UIWebView breaks horribly.

The 102 error has to do with some "Policy Changed" error in WebKit, which is poorly/non-documented anywhere.

Anybody have any idea? Any help is greatly appreciated!

EDIT: Looks like this is a cookie issue of some kind. Any reason why UIWebView would fail to load if the web server is setting a cookie via a background HTTP Request?

4

2 回答 2

5

好的,我已经想通了。

显然 UIWebView 不喜欢使用全局 cookie 存储的 URLConnection HTTPRequests(甚至 ASIHTTPRequest),直到它这样做。所以现在我的应用程序抛出了一个简单的 HTML 页面,以允许由 UIWebView 设置 cookie,并且每个“下游”的人显然都是一个快乐的露营者,通过 NSOperation 和 UIWebViews 的 API 请求。

万岁!

于 2010-03-03T18:30:37.017 回答
0

我不清楚您要在这里完成什么, UIWebView 将自行异步加载 NSRequest 。performSelectorOnMainThread:要检查的一件事是使用NSOperation中的一种方法确保您在代码中与 UIWebView 进行的任何交互都在主线程上 。

于 2010-03-02T15:57:43.840 回答