Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

8. Networking, JSON, XML, and Twitter > 8.4. Modifying a URL Request with NSMut...

8.4. Modifying a URL Request with NSMutableURLRequest

Problem

You want to adjust various HTTP headers and settings of a URL request before passing it to a URL connection.

Solution

This technique is the basis of many useful recipes shown later in this chapter. Use NSMutableURLRequest instead of NSURLRequest.

Discussion

A URL request can be either mutable or immutable. A mutable URL request can be changed after it has been allocated and initialized, whereas an immutable URL request cannot. Mutable URL requests are the target of this recipe. You can create them using the NSMutableURLRequest class.

Let’s have a look at an example where we will change the timeout interval of a URL request after we have allocated and initialized it:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial