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

1 Answer 1

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");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.