tailieunhanh - Phát triển ứng dụng cho iPhone và iPad - part 32

Tham khảo tài liệu 'phát triển ứng dụng cho iphone và ipad - part 32', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | iPhone SDK and the Web 279 NSLog @ connection willSendRequest redirectResponse return request The next delegate method is connection didReceiveAuthenticationChallenge . You will receive this message if the web server that you are calling requires authentication to complete the request. Because I am trying to keep this example simple to show the basics of using the URL Loading System the example will not use any authentication. However in a production application you will often be required to authenticate to retrieve data from a URL. When the connection didReceiveAuthenticationChallenge method is called you can respond in one of three ways Provide the necessary credentials by creating an NSURLCredential object and populating it with the data that the server expects. You can determine what the server expects by interrogating the NSURLAuthenticationChallenge object that you receive as a parameter to the didReceiveAuthenticationChallenge method. Attempt to continue without passing credentials. You can do this by calling the continueWithoutCredentialsForAuthenticationChallenge method on the sender of the challenge. Doing this will typically cause the request to fail but it may allow the user to retrieve a URL that does not require authentication. Cancel the request by calling the cancelAuthenticationChallenge method on the sender of the challenge. Doing this will send the connection didCancelAuthenticationChallenge message to your delegate. You can find more information about authentication in the URL Loading System Programming Guide in the Xcode help and on the Apple developer web site. In this implementation you will just log that the NSURLconnection object invoked this method 0 Called when the server requires authentication - void connection NSURLConnection connection dowobcdoii didReceiveAuthenticationChallenge NSURLAuthenticationChallenge challenge NSLog @ connection didReceiveAuthenticationChallenge If .