Do-It-Yourself Concurrency

Actually, our app isn’t as fast as we might like. Try scrolling the table. The scrolling is still choppy. This has been the case since way back in Custom Table Cells, where we started fetching the avatar images from their URLs. So let’s think about what’s causing the problem and whether we can fix it.

When the table asks us for a cell—in tableView(cellForRowAtIndexPath:)—we can easily set all the labels with strings from the ParsedTweet, but what we have for the avatar image is an NSURL. So we stop and load the data for that URL, make a new UIImage from it, and assign that to our custom cell’s UIImageView. This has to happen for each cell. Moreover, we can only work on one cell at a time. As a new cell comes into ...

Get iOS 9 SDK Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.