O'Reilly logo

Objective-C Recipes: A Problem-Solution Approach by Matthew Campbell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter    7

Consuming Web Content

This chapter covers how to use web content with Objective-C.

The recipes in this chapter will show you how to:

  • Download files with NSURL
  • Use web services with XML and JSON
  • Parse both XML and JSON data
  • Use NSURLConnection to asynchronously consume web content

7.1 Downloading a File

Problem

You want to download a file from the Internet.

Solution

Use NSURL to specify a URL for a file and then use NSData to download the contents of that file into your file system.

NOTE: URL stands for Uniform Resource Locator. A URL is a character string that specifies the location of an Internet resource. NSURL is a Foundation class that lets you use URLs in Objective-C.

How It Works

For this solution you must have a file ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required