开发者

iOS xcode, Web services, NSURLConnection second call fails

iPad development, iOS 4.3, objective-c, xcode 4.1.

I have created a wrapper class, which is used to call a method on a web service. It works fine when I make the first call, but fails on subsequent calls.

A method in my class, "runMethod::", opens a NSURLConnection and does the call asynchronously, with the wrapper class itself as the NSURLConnec开发者_StackOverflow社区tion delegate.

I have read somewhere that there's a fault with Android, which keeps a pool of connections. When you try to make a connection a second time it fails because the previous connection has been kept open, despite the code closing it. Hence, I suspect the problem is that the connection remains in the pool, and when I try to make another one it clashes? Maybe xcode has a similar issue?

And the symptoms of the failure are a seemingly random 'bad access' on a random line in one of the delegate selectors, which suggests this has something to do with threading - I understand that HTTP connections operate on their own thread.

I can provide the full wrapper class if need be, but anyone any ideas?


A 'bad access' error simply indicates that you're dereferencing an invalid pointer. This is most often due to improper memory management, such as failing to retain some object. Code would help, but first try the Analyze command in Xcode -- the static analyzer is pretty good at finding memory problems.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜