Kate
Kate

Reputation: 39

NSURLConnection - didFailWithError not invoked

I am using NSURLConnection to load data from server. So, in my Iphone Application had a button, when click on this button and internet connection is connected, the data will be loaded successfully. But later when I switched off the internet connection on Mac, and then click on that button again, the didFailWithError method does not invoked but other methods such as didReceiveResponse, connectionDidFinishLoading was get called.

Anyone encountered this kind of problem before? Or anyone know the reason of this problem?

Really appreciate for any comments, suggestions and solutions. Thanks.

Upvotes: 0

Views: 615

Answers (2)

fmccardoso
fmccardoso

Reputation: 11

Before changing any line in your code, try the same test with 4.3 simulator and then 5.0.

I've tried something similar (request to URL and connection is closed with no response), and using 4.3, didFailWithError is called. In 5.0, I get a didReceiveResponse with a status code 200 OK (!) and then connectionDidFinishLoading. Same code, same request, different OS versions...

Upvotes: 1

Serhii Mamontov
Serhii Mamontov

Reputation: 4932

Strange behavior especially because you turned internet off, but delegate still called for ** connectionDidFinishLoading** how this is possible? Also you wrote what "when click on this button and internet connection is connected" your code still initiated connection without internet?

It's possible, what you configured using of cached data and thats why you got strange behavior like this.

*nix systems by default have timeout for connection on BSD sockets which may don't tell you nothing about what connection is missed. But i think Mac OS/iOS configured for this kind of case.

Upvotes: 0

Related Questions