Skip to content

Commit

Permalink
Protect against a nil NSURLConnection or NSURLSession object being pa…
Browse files Browse the repository at this point in the history
…ssed to the swizzled delegate methods.

See #61 for motivation and background.
  • Loading branch information
ryanolsonk committed May 23, 2015
1 parent 7926345 commit a42af79
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Classes/Network/PonyDebugger/FLEXNetworkObserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ + (SEL)swizzledSelectorForSelector:(SEL)selector
/// The superclass implementation (and implementations in classes above that) will be executed without inteference if called from the original implementation.
+ (void)sniffWithoutDuplicationForObject:(NSObject *)object selector:(SEL)selector sniffingBlock:(void (^)(void))sniffingBlock originalImplementationBlock:(void (^)(void))originalImplementationBlock
{
// If we don't have an object to detect nested calls on, just run the original implmentation and bail.
// This case can happen if someone besides the URL loading system calls the delegate methods directly.
// See https://github.com/Flipboard/FLEX/issues/61 for an example.
if (!object) {
originalImplementationBlock();
return;
}

const void *key = selector;

// Don't run the sniffing block if we're inside a nested call
Expand Down

0 comments on commit a42af79

Please sign in to comment.