Created
October 5, 2017 15:44
-
-
Save phynet/14f8e3ae3cfb3f31e1f79f322ddd5b25 to your computer and use it in GitHub Desktop.
parse html string to string in swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
@objc extension NSString { | |
class func parseHTMLString(stringHTML: String) -> NSString { | |
return try! NSAttributedString( | |
data: stringHTML.data(using: String.Encoding.unicode, allowLossyConversion: true)!, | |
options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], | |
documentAttributes: nil).string as NSString | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment