Bronze Challenge: Printing the Response Information

The completion handler for dataTask(with:completionHandler:) provides an instance of URLResponse. When making HTTP requests, this response is of type HTTPURLResponse (a subclass of URLResponse). Print the statusCode and headerFields to the console. These properties are very useful when debugging web service calls.

Get iOS Programming: The Big Nerd Ranch Guide, 6th Edition 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.