Passing IIS basic authentication credentials from within a UIWebView

I have been trying to find the proper way to provide basic authentication credentials to access a website from within a UIWebView in my app. The simplest way to do this would be,

But this is not a secure way to pass credentials to access a website. After some research online and going through Apple documentation, I realised the proper way to do this is to initiate a NSURLConnection and catch the authentication challenge in the willSendRequestForAuthenticationChallenge delegate method and pass NSURLCredential as a response for the challenge. Continue reading