From 043ff93228785f2192f3f4987f8fdd28babf4b37 Mon Sep 17 00:00:00 2001 From: Aditya Atul Tirodkar Date: Sun, 2 Jun 2019 21:22:39 -0700 Subject: [PATCH] Fix merge collisions that got accidentally pushed --- EarlGrey/Additions/NSURLSession+GREYAdditions.m | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/EarlGrey/Additions/NSURLSession+GREYAdditions.m b/EarlGrey/Additions/NSURLSession+GREYAdditions.m index 821316bf4..f35cb6581 100644 --- a/EarlGrey/Additions/NSURLSession+GREYAdditions.m +++ b/EarlGrey/Additions/NSURLSession+GREYAdditions.m @@ -58,15 +58,10 @@ - (NSURLSessionDataTask *)greyswizzled_dataTaskWithRequest:(NSURLRequest *)reque [[delegate forwardingTargetForSelector:originalSel] class] ?: [delegate class]; if (![delegateClass instancesRespondToSelector:swizzledSel]) { - SEL originalSel = @selector(URLSession:task:didCompleteWithError:); - // If delegate does not exists or delegate does not implement the delegate method, then this + // If delegate does not exist or if it does not implement the delegate method, then this // request need not be tracked as its completion/failure does not trigger any delegate // callbacks. if ([delegate respondsToSelector:originalSel]) { - // This is to solve issues where there is a proxy delegate instead of the original instance (e.g. TrustKit). - // It responds YES to `respondsToSelector:` but `class_getInstanceMethod` returns nil. - // We attempt to take the forwarding target for the selector, if it exists. - delegateClass = [[delegate forwardingTargetForSelector:originalSel] class] ?: delegateClass; Class selfClass = [self class]; // Double-checked locking to prevent multiple swizzling attempts of the same class. @synchronized(selfClass) { @@ -86,13 +81,13 @@ - (NSURLSessionDataTask *)greyswizzled_dataTaskWithRequest:(NSURLRequest *)reque } GREYTaskCompletionBlock wrappedHandler = nil; - __weak __block id wTask; + __weak __block id weakTask; // If a handler has been provided then wrap it as delegate methods are not invoked for tasks with // completion blocks. if (handler) { wrappedHandler = ^(NSData *data, NSURLResponse *response, NSError *error) { handler(data, response, error); - [wTask grey_untrack]; + [weakTask grey_untrack]; }; } @@ -106,7 +101,7 @@ - (NSURLSessionDataTask *)greyswizzled_dataTaskWithRequest:(NSURLRequest *)reque if (!delegate && !handler) { [(id)task grey_neverTrack]; } else { - wTask = task; + weakTask = task; } return task; }