Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSURLConnection get URL

how i get the URL inside the following method ??

- (void)connectionDidFinishLoading:(NSURLConnection*)theConnection 
like image 363
Rony Avatar asked Jul 22 '10 12:07

Rony


2 Answers

Hey there's a comment from Mihai Damian that worked for me:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSURL *myURL = [[connection currentRequest] URL];

Cheers

like image 65
Wallter Avatar answered Sep 23 '22 03:09

Wallter


You ought to be able to do theConnection.request.URL, but you can't. Annoying, isn't it?

The simplest way is to just save the URL (or the whole NSURLRequest) that you were loading. If you're using multiple connections, you can store them in a dictionary. Note that -[NSMutableDictionary setObject:forKey:] copies keys, and NSURLConnections are not copyable; the workaround is to use CFDictionarySetValue instead:

CFDictionarySetValue((CFMutableDictionaryRef)dict, connection, request); 
like image 22
tc. Avatar answered Sep 21 '22 03:09

tc.