Adding NOT-MODIFIED (304) behavior to AFNetworking 2

After reading this stackoverflow post, I thought that I would simplify it by subclassing AFHTTPRequestOperationManager and wrap all of this stuff in a new method that I called GET:parameters:success:failure:unmodified:

According to this other stackoverflow post, NSURLCache needs a little bit of time to warm up, so I added a class initializer. From your AppDelegate’s application:didFinishLaunchingWithOptions: method you can call this early:

Using this new method is simple:

Hopefully this will be useful for you. If you’re worried about a nil unmodified or success block, you can prefix those calls with if (unmodified) unmodified(operation,responseObject) and if (success) success(operation,responseObject).

Leave a Reply

Your email address will not be published. Required fields are marked *