Skip to content

Instantly share code, notes, and snippets.

@alexshafran
Created January 22, 2014 05:01
Show Gist options
  • Save alexshafran/8553712 to your computer and use it in GitHub Desktop.
Save alexshafran/8553712 to your computer and use it in GitHub Desktop.
NSAttributedString+HTML
@implementation NSAttributedString (HTML)
+ (NSAttributedString *)attributedStringFromHTML:(NSString *)html
{
NSDictionary *options = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType};
NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding];
return [[NSAttributedString alloc] initWithData:data
options:options
documentAttributes:nil
error:nil];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment