title: NSAttributedString extension in swift 3
body: <p>I'm migrating my code to swift 3 and I'm having a hard time with this extension that was working on the previous swift version.</p>
  
  <pre><code>extension Data {
      var attributedString: NSAttributedString? {
          do {
              return try NSAttributedString(data: self, options:[NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: String.Encoding.utf8], documentAttributes: nil)
          } catch let error as NSError {
              print(error.localizedDescription)
          }
          return nil
      }
  }
  </code></pre>
  
  <p>Now when I try to call this piece of code I get an exception error like this</p>
  
  <pre><code>error: warning: couldn't get required object pointer (substituting NULL): Couldn't load 'self' because its value couldn't be evaluated
  </code></pre>
  
  <p>That's how I call the method from my view controller</p>
  
  <pre><code>let htmlCode = "&lt;html&gt;&lt;head&gt;&lt;style type=\"text/css\"&gt;@font-face {font-family: Avenir-Roman}body {font-family: Avenir-Roman;font-size:15;margin: 0;padding: 0}&lt;/style&gt;&lt;/head&gt;&lt;body bgcolor=\"#FBFBFB\"&gt;" + htmlBodyCode + "&lt;/body&gt;"
  newsDescription.attributedText = htmlCode.utf8Data?.attributedString
  </code></pre>