Calculating string sizes on iPhone on a background thread

Posted by jbrennan on Stack Overflow See other posts from Stack Overflow or by jbrennan
Published on 2010-03-22T03:01:04Z Indexed on 2010/03/22 3:01 UTC
Read the original article Hit count: 436

Filed under:
|
|
|
|

I've got some somewhat hefty string size calculations happening in my app (each one takes close to 500ms, and happens when the user scrolls to a new "page" in my app (like the Weather app). The delay only happens once per page, as the calculation only needs to be run once (and can even be cached for subsequent launches with the same data).

Anyway, I still like to not block the UI for this type of work, as to me it screams using threads, but I know UIKit is not meant to be used from other threads. (I know NSString is not part of UIKit, but the string sizing methods are part of the UIKitAdditions...)

So how should I go about doing this? What's the best way to not block the UI and do so safely?

© Stack Overflow or respective owner

Related posts about nsstring

Related posts about iphone