Network manager with NSURLConnection
<p>I am trying to create something like a Network Manager using NSUrlConnections.
For that, I want to be able to send multiple requests, but I also want to be able to identify the client(delegate) that made the request when the response arrives. 
I have created a NSDictionary like this:</p>

<pre><code>NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:SERVER_TIMEOUT];
....
[clients setObject:client forKey:connection];
</code></pre>

<p>in "- (void)connectionDidFinishLoading:(NSURLConnection *)connection" I have something like this:</p>

<pre><code>client = (id&lt;RTANetworkDelegate&gt;)[clients objectForKey:connection];
[clients removeObjectForKey:connection];
</code></pre>

<p>The Network Manager is the delegate for all the connections, I do some preprocessing and then I send the (parsed) response to the right delegate, that sent the request in the first place.</p>

<p>Unfortunately, it appears that a NSMutableURLRequest cannot be set as a key in a dictionary since it does not have the copyWithZone method and I get the error:</p>

<blockquote>
  <p>-[NSURLConnection copyWithZone:]:
  unrecognized selector sent to
  instance</p>
</blockquote>

<p>Any help would be much appreciated! 
Thanks!</p>

<p>=======================================</p>

<p>[Edit] I already found this in the meantime:</p>

<p><a href="http://blog.emmerinc.be/index.php/2009/03/15/multiple-async-nsurlconnections-example/" rel="nofollow">http://blog.emmerinc.be/index.php/2009/03/15/multiple-async-nsurlconnections-example/</a></p>

<p>It seems to solve my problem.. I still don't know if it's the best solution though. I thought I would post it here since it might help others too.</p>
