Monday, 29 September 2014

Multiple iOS GET Requests (Dynamic Number of Requests)



I am using an online API to retrieve random famous quotes. In my code, I use:



NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urloftheapi]
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60];
[request setHTTPMethod:@"GET"];


NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection start];
[connection release];


However, I want it to pull in possibly more than one quote. The API doesn't include a function for multiple quotes, so I would need to run more than one NSMutableURLRequest to get it all. However, since it could be 1 request, and could be several, I'm not sure the best way to implement this in code. Thoughts?


No comments:

Post a Comment