Advertisement
shuklavatsal1992

HTML to NSAttributedString

Aug 25th, 2022
1,448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.44 KB | None | 0 0
  1. func convertHtml() -> NSAttributedString{
  2.         if let theData = self.data(using: .utf16) {
  3.             do {
  4.                 let theString = try NSAttributedString(data: theData, options: [.documentType: NSAttributedString.DocumentType.html], documentAttributes: nil)
  5.                 return NSAttributedString(attributedString: theString)
  6.             } catch {  print("\(error)")  }
  7.         }
  8.         return NSAttributedString(self)
  9.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement