The standard examples I'm seeing in iOS to do a simple GET HTTP connection is to:
NSString *finalURLstring = @"http://www.somesite.com?value=2";
NSURL *url = [NSURL URLWithString:finalURLstring];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSURLConnection *urlConnection = [NSURLConnection connectionWithRequest:request delegate:self];
Then implement these functions:
-(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
-(void) connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
-(void) connectionDidFinishLoading:(NSURLConnection*)connection
And if you have multiple connections you just create multiple NSURLConnections and compare them in connectionDidFinishLoading:
if (connection == urlConnection1)
// do something
else if (connection == urlConnection2)
// do something else
The issue with this is that you are created a new connection to the server each time right? Is it possible to create your NSURLConnection and reuse it? i.e. keep the connection open so you can make multiple calls instead of creating new connections on every call to the server?
Thanks for your help,
-David