Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Some websites are protected with usernames and passwords. NSURLConnection lets you access these sites by responding to authentication challenges. Prior to iOS 5, you may have handled credentials using delegate callbacks like this:
- (void)connection:(NSURLConnection *)connection
didReceiveAuthenticationChallenge:
(NSURLAuthenticationChallenge *)challenge
{
NSURLProtectionSpace *protectionSpace =
[[NSURLProtectionSpace alloc]
initWithHost:primaryHost port:0
protocol:@"http" realm:nil
authenticationMethod:nil];
NSURLCredential *credential =
[[NSURLCredentialStorage sharedCredentialStorage]
defaultCredentialForProtectionSpace:protectionSpace];
[[challenge sender] useCredential:credential
forAuthenticationChallenge:challenge];
}
- (void)connection:(NSURLConnection *)connection
didCancelAuthenticationChallenge:
(NSURLAuthenticationChallenge *)challenge
{
NSLog(@"Challenge cancelled");
}