Search code examples
iphoneiosnsurlconnectionnsurlconnectiondelegate

NSURLConnection didFailWithError connectionDidFinishLoading called at same time?


Regarding "didFailWithError" and "connectionDidFinishLoading"

Can they both be called? Or its always one or the other?


Solution

  • No, they cannot be called at the same time.

    After the delegate receives a message connection:didFailWithError:, it receives no further delegate messages for the specified connection.

    If the connection succeeds in downloading the request, the delegate receives the connectionDidFinishLoading: message. The delegate will receive no further messages for the connection and the NSURLConnection object can be released.

    http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html