Hey,
how i can show my Webview and connect auto. with Basic-Auth?
Is this correct or how would you do it?
@IBOutlet weak var WebView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let username = "user"
let password = "pw"
let loginString = String(format: "%@:%@", username, password)
let loginData = loginString.data(using: String.Encoding.utf8)!
let base64LoginString = loginData.base64EncodedString()
// create the request
let url = URL(string: "http://myurl.com/")
var request = URLRequest(url: url!)
request.httpMethod = "POST"
request.setValue("Basic \(base64LoginString)", forHTTPHeaderField: "Authorization")
let urlConnection = NSURLConnection(request: request, delegate: self)
WebView.loadRequest(request);