Chapter 9

Asynchronous URL Loading

In This Chapter

arrow Understanding synchronous and asynchronous processing

arrow Working with the URL loading system

arrow Adding a class to manage asynchronous loading

In the grand scheme of things, downloading only a small bit of data from the Internet has no impact on your app’s performance, but when the amount that you download begins to increase, you’re going to run into trouble. That’s because right now — the way our RoadTrip app is working — when the downloading is taking place, you can’t really do anything else in the app.

Again, this isn’t an issue in small, simple apps, but it’s something you must address if you’re creating industrial-strength applications. By this I mean not just business applications, but anything that uses web services that respond with a significant amount of content.

When it comes to solving your problem, you have three choices: a) take advantage of the asynchronous capabilities of the URL loading system, b) do your downloading in another thread, or c) do both.

Reviewing Your Choices

In Chapter 7, you sent your data request to a web service (and received the response) by using the following:

NSData *data = [NSURLConnection sendSynchronousRequest:request ...

Get iOS Cloud Development For Dummies now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.