I'm using an instance of NSURLConnection on the iPhone to request data from a server, managed by a delegate as usual. The requests are quite frequent (maybe once every 2 minutes say) and have a common and fixed URL. Rather than seeing the good instance of NSURLConnection being released after each download and then a new one being created:
Is there any worth in retaining the first connection and reusing it? (I'd hope so, one good authentication should be worth a thousand.)
If so, how do I reuse it? The standout method in the docs is
-start
but this seems to crash the app when called on an already used (and non-nil) instance of NSURLConnection. [The docs do say-start
"causes the receiver to begin loading data, if it has not already."]
In case it's of help with regard to the above questions, I am (was!) proposing:
if (connection_ == nil)
{
connection_ = [NSURLConnection connectionWithRequest:request
delegate:self];
}
else
{
[connection_ start];
}