How can I invoke custom code when a redirect happens while sending a request with the method:
+ (void)sendAsynchronousRequest:(NSURLRequest *)request queue:(NSOperationQueue *)queue completionHandler:(void (^)(NSURLResponse*, NSData*, NSError*))handler
?
I'm looking to replicate the behavior the NSURLConnectionDelegate method:
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
I don't think you can replicate the behavior, since sendAsynchronousRequest
only calls the completion handler given to it in the code block.
It seems that you must use the delegate method for this purpose. I don't see any benefit from using sendAsynchronousRequest
over the normal NSURLConnection
, except for the fact that you have to keep an ivar of NSMutableData and possibly NSURLConnection if there are multiple of them per instance of the class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With