0

I ma migrating over to Swift 2 and trying to resolve all the compile errors and have found the code the link below which is apparently the new way to process html text, but I cannot see how to use this in my functions in swift 2?

in swift 1.2 I used:

attributedText.appendAttributedString(htmlString.html2AttributedString)

and

extension String {

    var html2AttributedString:NSAttributedString {

        return NSAttributedString(data: dataUsingEncoding(NSUTF8StringEncoding)!,
            options: [NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType,
            NSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding],
            documentAttributes: nil,
            error: nil)!
    }
}

This is the new way of doing it apparently String extension

Community
  • 1
  • 1
Piginhat
  • 131
  • 9

1 Answers1

1

You can use the mentioned extension in the link How do I decode HTML entities in swift 2.0? like the following

var str = String(htmlEncodedString: "abc");
Community
  • 1
  • 1
Muneeba
  • 1,756
  • 10
  • 11