Inspecting the Response

To receive data from the network connection, implement two delegate methods:

- (void)connection:(NSURLConnection *)connectiondidReceiveResponse:(NSURLResponse *)response{    [self.connectionData setLength:0];}- (void)connection:(NSURLConnection *)connection    didReceiveData:(NSData *)data{    [self.connectionData appendData:data];}

The first method just sets the data length to zero when the response from the server is initiated. Note that, in some cases, this can happen more than once (if the server initiates a redirect, for example). The second method just appends any received data to a local data object.

When the network connection is complete, it will call this delegate method:

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK 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.