I’m making an application that is similar to Pages for iOS, in that it has a scrolling list of documents with thumbnails. The issue I’m having:
What is the safe way to make thumbnails of these documents on a background thread?
Most of UIKit is not thread safe and will throw exceptions, so how can I make a thumbnail of stuff when the rendering APIs will throw exceptions while I render in the background? Is it a better idea to render on the main thread during idle time?
For the record, it will be a text document, so its not just rendering an image downsized in the background as I know how to do that.
Thanks for any help.
Lucky for you, my friend, CoreGraphics is generally thread safe. This little project here is dedicated to PDF annotation; but can be used to get the thumbnail of a specific page and return a UIImage. It’s quite fast, assuming you do one page per document, and all relevant code can be found in the class called
PDFThumbNailFactory.For safety’s sake; I would return a CGImage, because UIImage is not thread safe.