将NSAttributedstring(与NSTextAttachment有图像)转换为HTML在ios obj c

我知道如何将常见的NSAttributedString (没有图像)转换成HTML。 我将图像设置为NSTextAttachment NSAttributedString 。 我怎么能把整个属性string转换成HTML?

 UIImage *image = [UIImage imageNamed:@"Test.png"]; NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init]; textAttachment.image = image; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:htmlString]; NSAttributedString *attstringImage = [NSAttributedString attributedStringWithAttachment:textAttachment]; [attributedString appendAttributedString:attstringImage]; NSAttributedString *titleContent = (NSAttributedString *)attributedString; NSDictionary *documentAttributes = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}; NSData *htmlData = [titleContent dataFromRange:NSMakeRange(0, titleContent.length) documentAttributes:documentAttributes error:NULL]; NSString *html = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding]; 

请快速回答我的build议