I need to calculate the height for the cell in tableView:heightForRowAtIndexPath: The function for setting up the attributed text from html is very expensive:
[[NSAttributedString alloc] initWithData:[html dataUsingEncoding:NSUnicodeStringEncoding] options:options documentAttributes:nil error:&error];
Creating the attributed string in forward in a background thread is not possible/solving the problem as the function uses some functionality from Webkit and can work only on the main thread.
I had to abandon the use of UITableView and used UIScrollView instead but then there is the issue with reusing the content views. It is managed for me in UITableView but tableView:heightForRowAtIndexPath: is really slow. I am using an off screen prototype cell (which can also include hierarchy of views - replies like in forum) to calculate the height with systemLayoutSizeFittingSize.
Also in the implementation with UITableView I used a dictionary with cached attributed strings but it was not that big gain in speed.