Reputation: 6297
Regarding "didFailWithError
" and "connectionDidFinishLoading
"
Can they both be called? Or its always one or the other?
Upvotes: 3
Views: 1772
Reputation: 13224
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.
Upvotes: 6
Reputation: 318854
While not obvious, the docs make a statement that only one of these two will be called. It either finishes successfully and connectionDidFinishLoading is called, or it fails with an error and didFailWithError is called. You can find this in the NSURLConnectionDataDelegate docs for the **connection:willSendRequest:redirectResponse: method.
Edit: It looks like the answer from @erkanyildiz shows the better info from the docs.
Upvotes: 3
Reputation: 3545
connectionDidFinishLoading:
Sent when a connection has finished loading successfully.
Successfully. Seems like always one or the other.
Upvotes: 1