I would advise you to use:
[[NSAttributedString alloc] initWithHTML:[@"Text<BR />" dataUsingEncoding:NSUTF8StringEncoding] documentAttributes:NULL];
I use this all the time and it works perfectly. I even made a macro out of it:
#define html2AttributedString(htmlString) \
[[[NSAttributedString alloc] initWithHTML:[(htmlString) dataUsingEncoding:NSUTF8StringEncoding] \
documentAttributes:NULL] autorelease]
And then, you can make macro for color, alignment, font, etc…
In short, you just need to replace all the "\n"
in your string with <BR />
and use the code provided above. For the replacement part, use:
[yourString stringByReplacingOccurrencesOfString:... withString:…];
For iOS, you can check out this page in which they give you a replacement.
Our initWithHTML methods aim to perfectly match the output from the
Mac version. This is possible to achieve for characters and I have
unit tests in place that make certain this keeps being perfect.
Regarding the attributes there are many things that have to be done
slightly different on iOS to achieve the same look. I won’t bother you
with the details there.