Html태그에 대해 찾아보다가 아래와 같은 사용방법을 찾았다.
테스트를 해봐야겠다..
let htmlString = "LCD Soundsystem was the musical project of producer <a href='http://www.last.fm/music/James+Murphy' class='bbcode_artist'>James Murphy</a>, co-founder of <a href='http://www.last.fm/tag/dance-punk' class='bbcode_tag' rel='tag'>dance-punk</a> label <a href='http://www.last.fm/label/DFA' class='bbcode_label'>DFA</a> Records. Formed in 2001 in New York City, New York, United States, the music of LCD Soundsystem can also be described as a mix of <a href='http://www.last.fm/tag/alternative%20dance' class='bbcode_tag' rel='tag'>alternative dance</a> and <a href='http://www.last.fm/tag/post%20punk' class='bbcode_tag' rel='tag'>post punk</a>, along with elements of <a href='http://www.last.fm/tag/disco' class='bbcode_tag' rel='tag'>disco</a> and other styles. <br />"
let htmlStringData = htmlString.dataUsingEncoding(NSUTF8StringEncoding)!
let options: [String: AnyObject] = [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: NSUTF8StringEncoding]
let attributedHTMLString = try! NSAttributedString(data: htmlStringData, options: options, documentAttributes: nil)
let string = attributedHTMLString.string
출처 : http://stackoverflow.com/questions/25983558/stripping-out-html-tags-from-a-string
'iOS' 카테고리의 다른 글
저장된 대용량 이미지 파일을 resize하기 (0) | 2017.05.10 |
---|---|
objective C block 순환참조에 대해... (0) | 2016.12.09 |
NSURLString 사용시 주의점 (0) | 2016.09.29 |
스토리보드에서 Segue호출 유의사항 (0) | 2016.09.29 |
UIActivityIndicatorView 사용시 주의점 (0) | 2016.09.23 |