Skip to content

Instantly share code, notes, and snippets.

@phynet
Created October 5, 2017 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phynet/14f8e3ae3cfb3f31e1f79f322ddd5b25 to your computer and use it in GitHub Desktop.
Save phynet/14f8e3ae3cfb3f31e1f79f322ddd5b25 to your computer and use it in GitHub Desktop.
parse html string to string in swift
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