Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSURLConnectionDelegate. How Do I Cancel an Authentication Challenge?

I am successfully using the rather awesome connection:didReceiveAuthenticationChallenge: delegate method of NSURLConnectionDelegate. Cool.

I want to properly support letting the user cancel out of an authentication challenge. So, the GUI I present to the user has a cancel button and the question is what behavior should happen behind that button.

Currently I do this [[challenge sender] cancelAuthenticationChallenge:challenge] and I have implemented the NSURLConnectionDelegate method connection:didCancelAuthenticationChallenge:. In the Apple docs I noticed this rather ambiguous note for this callback:

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

Huh? The callback method that actually fires is connection:didFailWithError:

Can someone please shed some light here?

like image 292
dugla Avatar asked Oct 07 '22 22:10

dugla


1 Answers

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

This just means that the delegate method in question wasn't part of a formal protocol, i.e. one declared using the @protocol directive. The methods in an informal protocol are usually documented along with the class that would call them.

The callback method that actually fires is connection:didFailWithError:

Both -connection:didCancelAuthenticationChallenge: and -connection:didFailWithError: have the same note about being part of an informal protocol prior to iOS 5.0. It sounds like your connection is failing to load the data, not being cancelled. You'd probably get the former message if you cancelled the challenge by calling:

[[challenge sender] cancelAuthenticationChallenge:challenge];

as described in Canceling the Connection.

like image 125
Caleb Avatar answered Oct 12 '22 11:10

Caleb