I had a need to display HTML text inside my iOS app. I have decided I will use the built-in method on NSAttributedString
, initWithData:options:document
That's a really good question. It turns out that (at least for me) it is always slower the first time I call the method, no matter if the debugger is attached or not. Here is why: The first time you parse an HTML-attributed string, iOS loads a whole JavaScriptCore engine and WebKit into memory. Watch:
The first time we run the method (before parsing the string) only 3 threads exist:
After the string is parsed, we have 11 threads:
Now the next time we run the method, most of those web-related threads are still in existence:
That explains why it's slow the first time and fast thereafter.