Although we are all in love with Objective-C, the power of a language itself is given by its inner features. Languages like Ada have a built-in concurrency model, while Objective-C needs external libraries (let’s say libdispatch) to try to achieve the same power of expression found in richer languages. The same happened for the implementation of the Actor Model. The standout language for the feature of asynchronous message passing using the actor model is Erlang. From Wikipedia: The actor model
Do you have a job opening?
Submit your 30 day Job Listing for FREE
So, we now have the functionality we’re looking for, but if you run this yourself you’ll see its super slow! The issue is that the images in these cells are downloading on the UI thread, one at a time, and they aren’t being cached at all. So let’s fix that.
Recently I read a that showed the disassembly of +[NSURLConnection sendAsynchronousRequest:queue:completionHandler:] mainly as a simple call to +[NSURLConnection sendSynchronousRequest:returningResponse:error:] dispatched on a global queue.
This isnt a tutorial, this is just some source code that you might find useful. This class will load images in the background so it wont lock your UI up!
- June 14, 2011