NSURLConnectionDelegate. How to cancel an authentication call?

I successfully use the pretty awesome delegate method connection:didReceiveAuthenticationChallenge:for NSURLConnectionDelegate. Cool.

I want to properly maintain permission to revoke a user from authentication. So, the GUI that I present to the user has a cancel button, and the question is what behavior should happen behind that button.

I am currently doing this [[challenge sender] cancelAuthenticationChallenge:challenge]and I have applied the NSURLConnectionDelegate method connection:didCancelAuthenticationChallenge:. In Apple docs, I noticed this rather controversial note for this callback:

Available as part of an unofficial protocol prior to iOS 5.0.

AND? The callback method actually worksconnection:didFailWithError:

Can someone shed some light here?

+5
source share
1 answer

Available as part of an unofficial protocol prior to iOS 5.0.

It simply means that the delegate method in question was not part of the formal protocol, that is, one declared using the @protocol directive. Methods in an unofficial protocol are usually documented along with the class that called them.

The inverse method that actually fires is the connection: didFailWithError:

Both -connection:didCancelAuthenticationChallenge:and -connection:didFailWithError:have one and the same note that they are part of an informal protocol to iOS 5.0. It looks like your connection is not loading data, and not canceling. You probably received the former message if you canceled the call by calling:

[[challenge sender] cancelAuthenticationChallenge:challenge];

as described in Cancel connection .

+4

All Articles