I have an NSAttributed string (coming from HTML) that I set for a UITextView.
- (void)setHtml:(NSString *)html {
NSData *html
I also had to convert a NSAtttributedString to HTML in one of my projects. The code for doing this is as follows
//self.attributed String is the attributedString
NSDictionary *documentAttributes = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType};
NSData *htmlData = [self.attributedString dataFromRange:NSMakeRange(0, self.attributedString.length) documentAttributes:documentAttributes error:NULL];
NSString *htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
NSLog(@"%@", htmlString);