Creating a custom response serializer

In the Creating a web client using AFHTTPSessionManager recipe of this chapter, we used AFJSONResponseSerializer, which comes with AFNetworking, to serialize the response that is returned from the iTunes Search API. The standard AFNetworking response serializers work well for simple responses, but what if we want to create a custom serializer that would parse the response for us rather than just send back an NSDictionary object? We can subclass any of the response serializers provided by AFNetworking to accomplish that.

In this recipe, we will be subclassing AFJSONResponseSerializer so that our ITunesClient class returns an NSArray object that contains an array of objects that in turn contains the information ...

Get iOS and OS X Network Programming Cookbook now with O’Reilly online learning.

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