Commits

Martijn The committed ad385a9 Merge

Merged in fightingmonk/nsurlconnectionvcr/fix-arc-retain (pull request #3)

cast IMP of sendAsynchronousRequest:queue:completionHandler: to a typed function pointer, preventing ARC from calling objc_retain() on arbitrary register contents

Comments (0)

Files changed (1)

NSURLConnectionVCR/NSURLConnectionVCR.m

         return (id)^(id _self, NSURLRequest *request, NSOperationQueue *queue, void (^handler)(NSURLResponse*, NSData*, NSError*) ) {
             __block VCRCache *cache = [VCRCache loadCacheForRequest:request];
             if (cache == nil) {
-                origImps[2](_self, sel, request, queue, ^(NSURLResponse *response, NSData *data, NSError *error){
+                void (*_method_invoke_void)(id, SEL, NSURLRequest *, NSOperationQueue *, void (^)(NSURLResponse*, NSData*, NSError*)) =
+                    (void (*)(id, SEL, NSURLRequest *, NSOperationQueue *, void (^)(NSURLResponse*, NSData*, NSError*)))
+                    origImps[2];
+
+                _method_invoke_void(_self, sel, request, queue, ^(NSURLResponse *response, NSData *data, NSError *error){
                     cache = [VCRCache storeResponse:response withResponseBody:data forRequest:request success:NULL];
                     handler(cache.response, cache.responseBody, error);
                 });