Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 1.38 KB

README.md

File metadata and controls

31 lines (24 loc) · 1.38 KB

NSMutableAttributedString+HTML

A category on NSMutableAttributedString to add HTML features for UIKit that normally only available in AppKit The OSX documentation is here

Originally extracted from Push

Usage

#import "NSMutableAttributedString+HTML.h"
NSString * htmlString = @"This is a <a href=\"http://www.example.com\">sample</a> html file";
NSMutableAttributedString * bodyAttributedText = [[NSMutableAttributedString alloc]
                                                   initWithHTML:[htmlString dataUsingEncoding:NSUTF8StringEncoding]
                                                   documentAttributes:nil];

NSString * htmlStringWithoutBaseURL = @"This is a <a href=\"/test/url\">sample</a> html file";
NSMutableAttributedString * bodyAttributedText = [[NSMutableAttributedString alloc]
                                                   initWithHTML:[htmlStringWithoutBaseURL dataUsingEncoding:NSUTF8StringEncoding]
                                                   baseURL:@"http://www.example.com"
                                                   documentAttributes:nil];

Contact

Christopher Guess [email protected]