NSURL from NSURLConnection?

It seems dead simply, because to create an NSURLConnection I usually do this:

 NSURL *theURL = [NSURL URLWithString:urlString]; NSURLRequest *req = [NSURLRequest requestWithURL:theURL]; NSURLConnection *connection = [NSURLConnection connectionWithRequest:req delegate:self]; 

But how can I get the URL back in the delegate methods? Not enough for myself (I start several connections at once, so this gets a little dirty). It seems that I should return the URL from the connection.

Did I miss something?

+4
source share
1 answer

In-connection: didReceiveResponse: you can get the url. Please note that this may not be the same URL from which you created the connection, since the connection might have been redirected.

 - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSURL * url = [response URL]; // The URL } 
+9
source

Source: https://habr.com/ru/post/1305129/


All Articles