NSAttributedString src not accessible

Hi, using this code:

        guard let data = data(using: .utf8) else { return NSAttributedString() }
        do {
            return try NSAttributedString(data: data, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil)
        } catch {
            return NSAttributedString()


to populate UITextView.attributedText with an html-based string, containing text and tags

the main problem that occured is that tag src attribute contains url that requires certificate-based authorization

as a result, image is not shown up at UITextView


as of logs, i get these messages:



2018-06-26 14:00:41.498543+0300 XXXXX[30309:836502] [] nw_proxy_resolver_create_parsed_array PAC evaluation error: NSURLErrorDomain: -1003

2018-06-26 14:19:19.719366+0300 XXXXX[30309:846556] Received XPC error Connection interrupted for message type 3 kCFNetworkAgentXPCMessageTypePACQuery


can open image url using browser


is there any way to make NSAttributedString being able to load these images? like, pass URLSession or something similar?


Swift 4


Thanks a lot.

Powered by WPeMatico

You may also like...

Comments are closed.