Skip to content

Instantly share code, notes, and snippets.

@externvoid
Last active August 29, 2015 14:25
Show Gist options
  • Save externvoid/c8c97934bf037641efc9 to your computer and use it in GitHub Desktop.
Save externvoid/c8c97934bf037641efc9 to your computer and use it in GitHub Desktop.
サニタイズされてしまったHTMLを、元に戻す。<とかを元に戻す。
// 本文ラベルを取得して、本文を設定する
let descriptionLabel = cell!.viewWithTag(2) as! UILabel
let htmlString = entry["contentSnippet"] as? String
do {
let astr =
try NSAttributedString(data:
htmlString!.dataUsingEncoding(NSUnicodeStringEncoding)!,
options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
documentAttributes: nil)
descriptionLabel.text = astr.string
} catch { }
// descriptionLabel.text = entry["contentSnippet"] as? String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment