美文网首页
iOS HTML转字符串

iOS HTML转字符串

作者: anny_4243 | 来源:发表于2022-10-18 15:34 被阅读0次
- (NSString *)htmlToString:(NSString *)htmlString {
   
    NSDictionary *options = @{ NSDocumentTypeDocumentAttribute :NSHTMLTextDocumentType,
    NSCharacterEncodingDocumentAttribute :@(NSUTF8StringEncoding) };
    NSData *data = [htmlString dataUsingEncoding:NSUTF8StringEncoding];
    NSAttributedString *string = [[NSAttributedString alloc] initWithData:data options:options documentAttributes:nil error:nil];
    return string.string;
}

相关文章

网友评论

      本文标题:iOS HTML转字符串

      本文链接:https://www.haomeiwen.com/subject/xtxszrtx.html