Till Swift 1.2 version, UIWebView LoadData was accepting nil values, but Swift 2.0 is throwing error "Swift does not conform to protocol NilLateralConvertible".
Swift 1.2: Works fine
self.webView.loadData(tempData!, MIMEType: "application/pdf", textEncodingName: nil, baseURL: nil)
Swift 2.0: Throws error
self.webView.loadData(tempData!, MIMEType: "application/pdf", textEncodingName: nil, baseURL: nil)
This works for me:
webView.loadData(pdfDownload, MIMEType: "application/pdf", textEncodingName: "", baseURL: NSURL())
Swift 3:
self.webView.loadData(tempData!, MIMEType: "application/pdf", textEncodingName: "UTF-8", baseURL: NSURL() as URL)
The default character encoding is UTF-8
so you can do in this way:
self.webView.loadData(tempData!, MIMEType: "application/pdf", textEncodingName: "UTF-8", baseURL: NSURL())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With