AFNetworking/AFNetworking — pull request #883 by OliverLetterer (2013-03-28 07:59:36+00:00)
Title: Should `AFHTTPClient` apply it's default values likes `defaultSSLPinningMode` to each enqueued operation?

This is a separations and continuation of pull request #878.

There are places in my code where I don't use the provided method `-[AFHTTPClient HTTPRequestOperationWithRequest:success:failure:]` but am still using `-[AFHTTPClient enqueueHTTPRequestOperation:]`. It bothers me and it feels wrong to me, that the `AFHTTPClient` instance is not applying its default values like `defaultSSLPinningMode` or `defaultCredential` to an operation in `-[AFHTTPClient enqueueHTTPRequestOperation:]`, if it has not been set explicitly otherwise by the user himself. In case I don't want default values to be applied, I could still add the operation to the operation queue by myself.

This pull request illustrates how this can be achieved for `defaultSSLPinningMode` with method swizzling on `AFURLConnectionOperation`. As a note, method swizzling is only used here to keep the public API as light weight as it is right now. The technique is similar to what `UIAppearence` is using and described by @steipete [here](http://petersteinberger.com/blog/2013/uiappearance-for-custom-views/).