Converting HTML to NSAttributedString

232 Views Asked by At

I am working on an ePub reader and it is going pretty well so far. But I need some performance running. Currently the used API to convert HTML strings to NSAttributedString objects is Apple's initialization method

- (instancetype)initWithData:(NSData *)data options:(NSDictionary *)options documentAttributes:(NSDictionary **)dict error:(NSError **)error NS_AVAILABLE_IOS(7_0);

The only issue with this method is that, it can't be done in the background. Only on the UI/Main Thread and it takes so much running memory.

Is there some other solution that can tweak my app up a little to enhance the performance and memory utilization?

1

There are 1 best solutions below

0
On

What you current code does, if by far the most efficient way. Load html ONCE and parse it to NSAttributedString's once, save them and render inside a custom view.